Introduce NavigationBarColorVerifier

This CL introduces a utility method to write tests that check whether
Window#setNavigationBarColor(int) is supported or not.

To use this, test methods only need to pass a callback that updates
the navigation bar color as requested then takes a screenshot of the
navigation bar region and returns it.

All the test method needs to do is to implement a callback that
receives color, updates the navigation bar color, takes a screenshot
of the navigation bar region, and returnts it.

  expectNavigationBarColorNotSupported(color -> {
      TestActivity.startSync(activity -> {
          final View view = new View(activity);
          activity.getWindow()
                  .setNavigationBarColor(navigationBarColor);

          view.setLayoutParams(new ViewGroup.LayoutParams(
                  ViewGroup.LayoutParams.MATCH_PARENT,
                  ViewGroup.LayoutParams.MATCH_PARENT));
          return view;
      });

      Thread.sleep(BEFORE_SCREENSHOT_WAIT);

      // Take the screenshot of the navigation bar
      final Bitmap bitmap = uiAutomation.takeScreenshot();
      return Bitmap.createBitmap(
              bitmap,
              0,                                  // X
              bitmap.getHeight() - navBarHeight,  // Y
              bitmap.getWidth(),                  // width
              navigationBarHeight);               // height
  }

Note that not all the Android devices support navigation bar /
navigation bar color.  The caller is responsible for using
NavigationBarColorVerifier appropriately.

Bug: 25706186
Test: atest CtsInputMethodTestCases
Change-Id: I29cee16e0eda679184e64b6c7ff24669360128f5
1 file changed