コード例 #1
0
ファイル: NavigateTest.java プロジェクト: xar369/chromium
  /** Test back and forward buttons. */
  @Restriction(RESTRICTION_TYPE_TABLET)
  @MediumTest
  @Feature({"Navigation"})
  public void testNavigateBackAndForwardButtons() throws InterruptedException {
    final String[] urls = {
      TestHttpServerClient.getUrl("chrome/test/data/android/navigate/one.html"),
      TestHttpServerClient.getUrl("chrome/test/data/android/navigate/two.html"),
      TestHttpServerClient.getUrl("chrome/test/data/android/navigate/three.html")
    };

    for (String url : urls) {
      navigateAndObserve(url, url);
    }

    final int repeats = 3;
    for (int i = 0; i < repeats; i++) {
      singleClickView(getActivity().findViewById(R.id.back_button));
      UiUtils.settleDownUI(getInstrumentation());
      assertEquals(
          String.format(
              Locale.US,
              "URL mismatch after pressing back button for the 1st time in repetition %d.",
              i),
          urls[1],
          getActivity().getActivityTab().getUrl());

      singleClickView(getActivity().findViewById(R.id.back_button));
      UiUtils.settleDownUI(getInstrumentation());
      assertEquals(
          String.format(
              Locale.US,
              "URL mismatch after pressing back button for the 2nd time in repetition %d.",
              i),
          urls[0],
          getActivity().getActivityTab().getUrl());

      singleClickView(getActivity().findViewById(R.id.forward_button));
      UiUtils.settleDownUI(getInstrumentation());
      assertEquals(
          String.format(
              Locale.US,
              "URL mismatch after pressing fwd button for the 1st time in repetition %d.",
              i),
          urls[1],
          getActivity().getActivityTab().getUrl());

      singleClickView(getActivity().findViewById(R.id.forward_button));
      UiUtils.settleDownUI(getInstrumentation());
      assertEquals(
          String.format(
              Locale.US,
              "URL mismatch after pressing fwd button for the 2nd time in repetition %d.",
              i),
          urls[2],
          getActivity().getActivityTab().getUrl());
    }
  }
コード例 #2
0
ファイル: PreferencesTest.java プロジェクト: mirror/chromium
  /**
   * Tests setting FontScaleFactor and ForceEnableZoom in AccessibilityPreferences and ensures that
   * ForceEnableZoom changes corresponding to FontScaleFactor.
   */
  @SmallTest
  @Feature({"Accessibility"})
  public void testAccessibilityPreferences() throws Exception {
    String accessibilityPrefClassname = AccessibilityPreferences.class.getName();
    AccessibilityPreferences accessibilityPref =
        (AccessibilityPreferences)
            startPreferences(getInstrumentation(), accessibilityPrefClassname).getFragmentForTest();
    SeekBarPreference textScalePref =
        (SeekBarPreference)
            accessibilityPref.findPreference(AccessibilityPreferences.PREF_TEXT_SCALE);
    SeekBarLinkedCheckBoxPreference forceEnableZoomPref =
        (SeekBarLinkedCheckBoxPreference)
            accessibilityPref.findPreference(AccessibilityPreferences.PREF_FORCE_ENABLE_ZOOM);
    NumberFormat percentFormat = NumberFormat.getPercentInstance();
    // Arbitrary value 0.4f to be larger and smaller than threshold.
    float fontSmallerThanThreshold = FontSizePrefs.FORCE_ENABLE_ZOOM_THRESHOLD_MULTIPLIER - 0.4f;
    float fontBiggerThanThreshold = FontSizePrefs.FORCE_ENABLE_ZOOM_THRESHOLD_MULTIPLIER + 0.4f;

    // Set the textScaleFactor above the threshold.
    userSetTextScale(accessibilityPref, textScalePref, fontBiggerThanThreshold);
    UiUtils.settleDownUI(getInstrumentation());
    // Since above the threshold, this will check the force enable zoom button.
    assertEquals(percentFormat.format(fontBiggerThanThreshold), textScalePref.getSummary());
    assertTrue(forceEnableZoomPref.isChecked());
    assertFontSizePrefs(true, fontBiggerThanThreshold);

    // Set the textScaleFactor below the threshold.
    userSetTextScale(accessibilityPref, textScalePref, fontSmallerThanThreshold);
    UiUtils.settleDownUI(getInstrumentation());
    // Since below the threshold and userSetForceEnableZoom is false, this will uncheck
    // the force enable zoom button.
    assertEquals(percentFormat.format(fontSmallerThanThreshold), textScalePref.getSummary());
    assertFalse(forceEnableZoomPref.isChecked());
    assertFontSizePrefs(false, fontSmallerThanThreshold);

    userSetTextScale(accessibilityPref, textScalePref, fontBiggerThanThreshold);
    // Sets onUserSetForceEnableZoom to be true.
    userSetForceEnableZoom(accessibilityPref, forceEnableZoomPref, true);
    UiUtils.settleDownUI(getInstrumentation());
    // Since userSetForceEnableZoom is true, when the text scale is moved below the threshold
    // ForceEnableZoom should remain checked.
    userSetTextScale(accessibilityPref, textScalePref, fontSmallerThanThreshold);
    assertTrue(forceEnableZoomPref.isChecked());
    assertFontSizePrefs(true, fontSmallerThanThreshold);
  }
コード例 #3
0
ファイル: NavigateTest.java プロジェクト: xar369/chromium
  /** Verify New Tab Open and Navigate. */
  @MediumTest
  @Feature({"Navigation"})
  public void testOpenAndNavigate() throws InterruptedException {
    final String url = TestHttpServerClient.getUrl("chrome/test/data/android/navigate/simple.html");
    navigateAndObserve(url, url);

    final int tabCount = getActivity().getCurrentTabModel().getCount();
    ChromeTabUtils.newTabFromMenu(getInstrumentation(), getActivity());
    UiUtils.settleDownUI(getInstrumentation());

    assertEquals(
        "Wrong number of tabs", tabCount + 1, getActivity().getCurrentTabModel().getCount());
    String result = typeInOmniboxAndNavigate(url);
    assertEquals(expectedLocation(url), result);
  }
コード例 #4
0
 public boolean openAutofillPopupAndWaitUntilReady(final AutofillSuggestion[] suggestions)
     throws InterruptedException {
   UiUtils.runOnUiThread(
       getActivity(),
       new Runnable() {
         @Override
         public void run() {
           mAutofillPopup.filterAndShow(suggestions, false);
         }
       });
   return CriteriaHelper.pollForCriteria(
       new Criteria() {
         @Override
         public boolean isSatisfied() {
           return mAutofillPopup.getListView().getChildCount() > 0;
         }
       });
 }
コード例 #5
0
  @Override
  public void setUp() throws Exception {
    super.setUp();
    ChromeShellActivity activity = launchChromeShellWithBlankPage();
    assertNotNull(activity);
    waitForActiveShellToBeDoneLoading();

    mMockAutofillCallback = new MockAutofillCallback();
    mWindowAndroid = new ActivityWindowAndroid(activity);
    final ViewAndroidDelegate viewDelegate =
        activity.getActiveContentViewCore().getViewAndroidDelegate();

    UiUtils.runOnUiThread(
        getActivity(),
        new Runnable() {
          @Override
          public void run() {
            mAutofillPopup =
                new AutofillPopup(
                    mWindowAndroid.getActivity().get(), viewDelegate, mMockAutofillCallback);
            mAutofillPopup.setAnchorRect(50, 500, 500, 50);
          }
        });
  }