Exemplo n.º 1
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);
  }
Exemplo n.º 2
0
  /*
  Bug http://crbug/415711
  */
  @MediumTest
  @Feature({"Downloads"})
  public void testDuplicateHttpPostDownload_Overwrite() throws Exception {
    // Download a file.
    loadUrl(TestHttpServerClient.getUrl("chrome/test/data/android/download/post.html"));
    waitForFocus();
    View currentView = getActivity().getActivityTab().getView();
    singleClickView(currentView);
    assertTrue(
        "Failed to finish downloading file for the first time.", waitForChromeDownloadToFinish());

    // Download a file with the same name.
    loadUrl(TestHttpServerClient.getUrl("chrome/test/data/android/download/post.html"));
    waitForFocus();
    currentView = getActivity().getActivityTab().getView();
    singleClickView(currentView);
    assertPollForInfoBarSize(1);
    assertTrue(
        "OVERWRITE button wasn't found", InfoBarUtil.clickPrimaryButton(getInfoBars().get(0)));
    assertTrue(
        "Failed to finish downloading file for the second time.", waitForChromeDownloadToFinish());

    assertTrue("Missing first download", hasDownload("superbo.txt", SUPERBO_CONTENTS));
    assertFalse(
        "Should not have second download", hasDownload("superbo (1).txt", SUPERBO_CONTENTS));
  }
Exemplo n.º 3
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());
  }
Exemplo n.º 4
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());
  }
Exemplo n.º 5
0
 /** Bug http://crbug/286315 @MediumTest @Feature({"Downloads"}) */
 @FlakyTest
 public void testDangerousDownload() throws Exception {
   loadUrl(TestHttpServerClient.getUrl("chrome/test/data/android/download/dangerous.html"));
   waitForFocus();
   View currentView = getActivity().getActivityTab().getView();
   singleClickView(currentView);
   assertPollForInfoBarSize(1);
   assertTrue("OK button wasn't found", InfoBarUtil.clickPrimaryButton(getInfoBars().get(0)));
   assertTrue(waitForGetDownloadToFinish());
   checkLastDownload("test.apk");
 }
Exemplo n.º 6
0
  /*
  Bug http://crbug/415711
  */
  @MediumTest
  @Feature({"Downloads"})
  public void testDuplicateHttpPostDownload_AllowMultipleInfoBars() throws Exception {
    assertFalse(hasDownload("superbo.txt", SUPERBO_CONTENTS));
    // Download a file.
    loadUrl(TestHttpServerClient.getUrl("chrome/test/data/android/download/post.html"));
    waitForFocus();
    View currentView = getActivity().getActivityTab().getView();
    singleClickView(currentView);
    assertTrue(
        "Failed to finish downloading file for the first time.", waitForChromeDownloadToFinish());

    // Download the file for the second time.
    loadUrl(TestHttpServerClient.getUrl("chrome/test/data/android/download/post.html"));
    waitForFocus();
    currentView = getActivity().getActivityTab().getView();
    singleClickView(currentView);
    assertPollForInfoBarSize(1);

    // Download the file for the third time.
    loadUrl(TestHttpServerClient.getUrl("chrome/test/data/android/download/post.html"));
    waitForFocus();
    currentView = getActivity().getActivityTab().getView();
    singleClickView(currentView);
    assertPollForInfoBarSize(2);

    // Now create two new files by clicking on the infobars.
    assertTrue(
        "CREATE NEW button wasn't found", InfoBarUtil.clickSecondaryButton(getInfoBars().get(0)));
    assertTrue("Failed to finish downloading the second file.", waitForChromeDownloadToFinish());
    assertPollForInfoBarSize(1);
    assertTrue(
        "CREATE NEW button wasn't found", InfoBarUtil.clickSecondaryButton(getInfoBars().get(0)));
    assertTrue("Failed to finish downloading the third file.", waitForChromeDownloadToFinish());

    assertTrue("Missing first download", hasDownload("superbo.txt", SUPERBO_CONTENTS));
    assertTrue("Missing second download", hasDownload("superbo (1).txt", SUPERBO_CONTENTS));
    assertTrue("Missing third download", hasDownload("superbo (2).txt", SUPERBO_CONTENTS));
  }
Exemplo n.º 7
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());
  }
Exemplo n.º 8
0
  /*
  Bug http://crbug/481758
  */
  @CommandLineFlags.Add(ChromeSwitches.DISABLE_DOCUMENT_MODE)
  @MediumTest
  @Feature({"Downloads"})
  public void testDuplicateHttpPostDownload_OpenNewTabAndReplace() throws Exception {
    final String url = TestHttpServerClient.getUrl("chrome/test/data/android/download/get.html");

    // Create the file in advance so that duplicate download infobar can show up.
    File dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
    assertTrue(dir.isDirectory());
    final File file = new File(dir, "test.gzip");
    if (!file.exists()) {
      assertTrue(file.createNewFile());
    }

    // Open in a new tab again.
    loadUrl(url);
    waitForFocus();

    View currentView = getActivity().getActivityTab().getView();
    TouchCommon.longPressView(currentView);
    getInstrumentation()
        .invokeContextMenuAction(getActivity(), R.id.contextmenu_open_in_new_tab, 0);
    waitForNewTabToStabilize(2);

    goToLastTab();
    assertPollForInfoBarSize(1);

    // Now create two new files by clicking on the infobars.
    assertTrue(
        "OVERWRITE button wasn't found", InfoBarUtil.clickPrimaryButton(getInfoBars().get(0)));

    // Try to wait for download to finish. This will fail if there is no external Internet
    // connection. Android's DownloadManager will abort download request when there is
    // no Internet connection, even though we are connecting to a local host.
    waitForGetDownloadToFinish();
  }
Exemplo n.º 9
0
  /** Bug http://crbug/253711 Bug http://crbug/415711 @MediumTest @Feature({"Downloads"}) */
  @FlakyTest
  public void testDuplicateHttpPostDownload_CreateNew() throws Exception {
    // Download a file.
    loadUrl(TestHttpServerClient.getUrl("chrome/test/data/android/download/post.html"));
    waitForFocus();
    View currentView = getActivity().getActivityTab().getView();
    singleClickView(currentView);
    assertTrue(
        "Failed to finish downloading file for the first time.", waitForChromeDownloadToFinish());

    // Download a file with the same name.
    loadUrl(TestHttpServerClient.getUrl("chrome/test/data/android/download/post.html"));
    waitForFocus();
    currentView = getActivity().getActivityTab().getView();
    singleClickView(currentView);
    assertPollForInfoBarSize(1);
    assertTrue(
        "CREATE NEW button wasn't found", InfoBarUtil.clickSecondaryButton(getInfoBars().get(0)));
    assertTrue(
        "Failed to finish downloading file for the second time.", waitForChromeDownloadToFinish());

    assertTrue("Missing first download", hasDownload("superbo.txt", SUPERBO_CONTENTS));
    assertTrue("Missing second download", hasDownload("superbo (1).txt", SUPERBO_CONTENTS));
  }