0

Android newbie here! I have an Activity class I'll call SomeActivity, which uses a theme BlueTheme:

<style name=“BlueTheme” parent="@style/AnotherTheme”>
  …
</style>

How can I verify that my activity is using the theme in a test? Activity has a getTheme method, but I'm struggling to find some way to identify which theme it is.

@Test
public void verifyTheme() {
    
  SomeActivity activity = setUpActivityControllerAndGetActivity();

  // This represents what I would like to do, but don’t know how
  String actualThemeName = activity.getTheme().getThemeName();

  assertThat(actualThemeName).isEqualTo(“BlueTheme”);
}
Kaitlyn
  • 201
  • 3
  • 15
  • The answer found in the following link may help. https://stackoverflow.com/questions/10302853/android-theme-name-from-theme-id – RStevoUK Feb 11 '21 at 01:20
  • Unfortunately, I don't know the resource id of the theme, so I'm not sure if those methods will work for me. – Kaitlyn Feb 12 '21 at 02:30

0 Answers0