Quran_android: Write a unit test for AudioUtils

Created on 8 Feb 2017  路  3Comments  路  Source: quran/quran_android

i introduced a crash a8f2b2d742026a542b8751a622252e584e6e72b6 that i fixed in 02c953d91b3dcae6a2bf6a808854d2d5921986be. a unit test would have easily caught this.

i think the steps here are:

  1. change the class to a Singleton class
  2. inject the context so we don't have to pass it along everywhere
  3. add tests for some of these methods and document them
PRs Welcome

Most helpful comment

Happy to pick this up

All 3 comments

Happy to pick this up

@ahmedre when you say turn it into a Singleton, you mean via Dagger or just by plain Java?

Also I presume this involves turning static methods to instance methods?

either one - preferably dagger though.

so it'd look like:

@Singleton
public class AudioUtils {
    private final Context appContext;

    @Inject
    public AudioUtils(Context appContext) {
        this.appContext = appContext;
    }
}

and then when you want to use it (i.e. in PagerActivity for example), you'd just do

@Inject AudioUtils audioUtils;

since PagerActivity already deals with injection for you, you should be able to use it easily whenever you need it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mgalaleldin picture mgalaleldin  路  3Comments

Ahmed9914 picture Ahmed9914  路  4Comments

MahmoudMabrok picture MahmoudMabrok  路  4Comments

ibnharoon picture ibnharoon  路  7Comments

ahmedre picture ahmedre  路  7Comments