Ejemplo n.º 1
0
  /** Verify InfoBarContainers swap the WebContents they are monitoring properly. */
  @MediumTest
  @Feature({"Browser", "Main"})
  public void testInfoBarContainerSwapsWebContents() throws InterruptedException {
    // Add an infobar.
    LocationSettingsTestUtil.setSystemLocationSettingEnabled(true);
    loadUrl(mTestServer.getURL(GEOLOCATION_PAGE));
    assertTrue("InfoBar not added", mListener.addInfoBarAnimationFinished());
    assertEquals("Wrong infobar count", 1, getInfoBars().size());

    // Swap out the WebContents and send the user somewhere so that the InfoBar gets removed.
    InfoBarTestAnimationListener removeListener = new InfoBarTestAnimationListener();
    getActivity().getActivityTab().getInfoBarContainer().setAnimationListener(removeListener);
    ThreadUtils.runOnUiThread(
        new Runnable() {
          @Override
          public void run() {
            WebContents newContents = WebContentsFactory.createWebContents(false, false);
            getActivity().getActivityTab().swapWebContents(newContents, false, false);
          }
        });
    loadUrl(HELLO_WORLD_URL);
    assertTrue("InfoBar not removed.", removeListener.removeInfoBarAnimationFinished());
    assertEquals("Wrong infobar count", 0, getInfoBars().size());

    // Revisiting the original page should make the InfoBar reappear.
    InfoBarTestAnimationListener addListener = new InfoBarTestAnimationListener();
    getActivity().getActivityTab().getInfoBarContainer().setAnimationListener(addListener);
    loadUrl(mTestServer.getURL(GEOLOCATION_PAGE));
    assertTrue("InfoBar not added", addListener.addInfoBarAnimationFinished());
    assertEquals("Wrong infobar count", 1, getInfoBars().size());
  }
Ejemplo n.º 2
0
  /** Verify Geolocation creates an InfoBar and that it's destroyed when navigating back. */
  @MediumTest
  @Feature({"Browser"})
  public void testInfoBarForGeolocationDisappearsOnBack() throws InterruptedException {
    LocationSettingsTestUtil.setSystemLocationSettingEnabled(true);
    loadUrl(HELLO_WORLD_URL);
    loadUrl(mTestServer.getURL(GEOLOCATION_PAGE));
    assertTrue("InfoBar not added.", mListener.addInfoBarAnimationFinished());

    assertEquals("Wrong infobar count", 1, getInfoBars().size());

    // Navigate back and ensure the InfoBar has been removed.
    getInstrumentation()
        .runOnMainSync(
            new Runnable() {
              @Override
              public void run() {
                getActivity().getActivityTab().goBack();
              }
            });
    CriteriaHelper.pollForCriteria(
        new Criteria() {
          @Override
          public boolean isSatisfied() {
            return getInfoBars().isEmpty();
          }
        },
        MAX_TIMEOUT,
        CHECK_INTERVAL);
    assertTrue("InfoBar not removed.", mListener.removeInfoBarAnimationFinished());
  }
Ejemplo n.º 3
0
  /** Verifies the hung renderer InfoBar can kill the hung renderer. */
  @Smoke
  @MediumTest
  @Feature({"Browser", "Main"})
  public void testInfoBarForHungRendererCanKillRenderer() throws InterruptedException {
    loadUrl(HELLO_WORLD_URL);

    // Fake an unresponsive renderer signal.
    ThreadUtils.runOnUiThread(
        new Runnable() {
          @Override
          public void run() {
            CommandLine.getInstance().appendSwitch(ChromeSwitches.ENABLE_HUNG_RENDERER_INFOBAR);
            getActivity()
                .getActivityTab()
                .getTabWebContentsDelegateAndroid()
                .rendererUnresponsive();
          }
        });
    assertTrue("InfoBar not added", mListener.addInfoBarAnimationFinished());

    // Make sure it has Kill/Wait buttons.
    final List<InfoBar> infoBars = getInfoBars();
    assertEquals("Wrong infobar count", 1, infoBars.size());
    assertTrue(InfoBarUtil.hasPrimaryButton(infoBars.get(0)));
    assertTrue(InfoBarUtil.hasSecondaryButton(infoBars.get(0)));

    // Activite the Kill button.
    ThreadUtils.runOnUiThread(
        new Runnable() {
          @Override
          public void run() {
            InfoBarUtil.clickPrimaryButton(infoBars.get(0));
          }
        });

    // The renderer should have been killed and the InfoBar removed.
    assertTrue("InfoBar not removed.", mListener.removeInfoBarAnimationFinished());
    assertTrue("Wrong infobar count", getInfoBars().isEmpty());
    CriteriaHelper.pollForCriteria(
        new Criteria() {
          @Override
          public boolean isSatisfied() {
            return getActivity().getActivityTab().isShowingSadTab();
          }
        },
        MAX_TIMEOUT,
        CHECK_INTERVAL);
  }
Ejemplo n.º 4
0
  /** Verify Geolocation creates an InfoBar. */
  @Smoke
  @MediumTest
  @Feature({"Browser", "Main"})
  public void testInfoBarForGeolocation() throws InterruptedException {
    LocationSettingsTestUtil.setSystemLocationSettingEnabled(true);
    loadUrl(mTestServer.getURL(GEOLOCATION_PAGE));
    assertTrue("InfoBar not added", mListener.addInfoBarAnimationFinished());

    // Make sure it has OK/Cancel buttons.
    List<InfoBar> infoBars = getInfoBars();
    assertEquals("Wrong infobar count", 1, infoBars.size());
    assertTrue(InfoBarUtil.hasPrimaryButton(infoBars.get(0)));
    assertTrue(InfoBarUtil.hasSecondaryButton(infoBars.get(0)));

    loadUrl(HELLO_WORLD_URL);
    assertTrue("InfoBar not removed.", mListener.removeInfoBarAnimationFinished());
    assertTrue("Wrong infobar count", getInfoBars().isEmpty());
  }
Ejemplo n.º 5
0
  /** Verify PopUp InfoBar. */
  @Smoke
  @MediumTest
  @Feature({"Browser", "Main"})
  public void testInfoBarForPopUp() throws InterruptedException {
    loadUrl(mTestServer.getURL(POPUP_PAGE));
    assertTrue("InfoBar not added", mListener.addInfoBarAnimationFinished());

    List<InfoBar> infoBars = getInfoBars();
    assertEquals("Wrong infobar count", 1, infoBars.size());
    assertTrue(InfoBarUtil.hasPrimaryButton(infoBars.get(0)));
    assertFalse(InfoBarUtil.hasSecondaryButton(infoBars.get(0)));
    InfoBarUtil.clickPrimaryButton(infoBars.get(0));
    assertTrue("InfoBar not removed.", mListener.removeInfoBarAnimationFinished());
    assertEquals("Wrong infobar count", 0, infoBars.size());

    // A second load should not show the infobar.
    loadUrl(mTestServer.getURL(POPUP_PAGE));
    assertFalse("InfoBar added when it should not", mListener.addInfoBarAnimationFinished());
  }
Ejemplo n.º 6
0
  /** Verifies the unresponsive renderer notification creates an InfoBar. */
  @Smoke
  @MediumTest
  @Feature({"Browser", "Main"})
  public void testInfoBarForHungRenderer() throws InterruptedException {
    loadUrl(HELLO_WORLD_URL);

    // Fake an unresponsive renderer signal.
    ThreadUtils.runOnUiThread(
        new Runnable() {
          @Override
          public void run() {
            CommandLine.getInstance().appendSwitch(ChromeSwitches.ENABLE_HUNG_RENDERER_INFOBAR);
            getActivity()
                .getActivityTab()
                .getTabWebContentsDelegateAndroid()
                .rendererUnresponsive();
          }
        });
    assertTrue("InfoBar not added", mListener.addInfoBarAnimationFinished());

    // Make sure it has Kill/Wait buttons.
    List<InfoBar> infoBars = getInfoBars();
    assertEquals("Wrong infobar count", 1, infoBars.size());
    assertTrue(InfoBarUtil.hasPrimaryButton(infoBars.get(0)));
    assertTrue(InfoBarUtil.hasSecondaryButton(infoBars.get(0)));

    // Fake a responsive renderer signal.
    ThreadUtils.runOnUiThread(
        new Runnable() {
          @Override
          public void run() {
            getActivity().getActivityTab().getTabWebContentsDelegateAndroid().rendererResponsive();
          }
        });
    assertTrue("InfoBar not removed.", mListener.removeInfoBarAnimationFinished());
    assertTrue("Wrong infobar count", getInfoBars().isEmpty());
  }