0

In my main activity I observe Livedata and change the background accordingly using getWindow.setBackgroundDrawable(drawable));

My code:

backgroundImageViewModel.getBackgroundImageLive().observe(this, new Observer<BackgroundImage>() 
            @Override
            public void onChanged(BackgroundImage backgroundImage) {
                if(backgroundImage == null ||backgroundImage.getDrawable() == null) {
                    return;
                }
                Log.d(TAG, "drawable: " + backgroundImage.getDrawable());
                getWindow().setBackgroundDrawable(backgroundImage.getDrawable());
            }
        });

In my espresso test, I update the live data. But how can I test in if the background drawable changed?

Gerke
  • 926
  • 1
  • 10
  • 20
  • Dis you check this thread ? https://stackoverflow.com/a/44538570/5132305 – ponkape Feb 14 '20 at 14:16
  • 1
    yes, I did, the difference is, that I am not checking any ImageView but the background which I set using ```getWindow().setBackgroundDrawable()``` – Gerke Feb 14 '20 at 14:33

0 Answers0