コード例 #1
0
ファイル: DownloadTest.java プロジェクト: Workday/OpenFrame
  /*
  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));
  }
コード例 #2
0
ファイル: DownloadTest.java プロジェクト: Workday/OpenFrame
 /** 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");
 }
コード例 #3
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());
  }
コード例 #4
0
ファイル: DownloadTest.java プロジェクト: Workday/OpenFrame
  /*
  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();
  }