Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: chrome/browser/apps/guest_view/web_view_browsertest.cc

Issue 2835233002: Fix integration tests in src/chrome and src/extensions so that we can turn on IO thread checks wi... (Closed)
Patch Set: ready for review Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <queue> 5 #include <queue>
6 #include <set> 6 #include <set>
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
11 #include "base/files/scoped_temp_dir.h" 11 #include "base/files/scoped_temp_dir.h"
12 #include "base/guid.h" 12 #include "base/guid.h"
13 #include "base/location.h" 13 #include "base/location.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/path_service.h" 15 #include "base/path_service.h"
16 #include "base/process/process.h" 16 #include "base/process/process.h"
17 #include "base/run_loop.h" 17 #include "base/run_loop.h"
18 #include "base/single_thread_task_runner.h" 18 #include "base/single_thread_task_runner.h"
19 #include "base/strings/string_number_conversions.h" 19 #include "base/strings/string_number_conversions.h"
20 #include "base/strings/stringprintf.h" 20 #include "base/strings/stringprintf.h"
21 #include "base/strings/utf_string_conversions.h" 21 #include "base/strings/utf_string_conversions.h"
22 #include "base/threading/thread_restrictions.h"
22 #include "base/threading/thread_task_runner_handle.h" 23 #include "base/threading/thread_task_runner_handle.h"
23 #include "build/build_config.h" 24 #include "build/build_config.h"
24 #include "chrome/app/chrome_command_ids.h" 25 #include "chrome/app/chrome_command_ids.h"
25 #include "chrome/browser/apps/app_browsertest_util.h" 26 #include "chrome/browser/apps/app_browsertest_util.h"
26 #include "chrome/browser/chrome_content_browser_client.h" 27 #include "chrome/browser/chrome_content_browser_client.h"
27 #include "chrome/browser/chrome_notification_types.h" 28 #include "chrome/browser/chrome_notification_types.h"
28 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 29 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
29 #include "chrome/browser/download/download_history.h" 30 #include "chrome/browser/download/download_history.h"
30 #include "chrome/browser/download/download_prefs.h" 31 #include "chrome/browser/download/download_prefs.h"
31 #include "chrome/browser/download/download_service.h" 32 #include "chrome/browser/download/download_service.h"
(...skipping 2519 matching lines...) Expand 10 before | Expand all | Expand 10 after
2551 << message_; 2552 << message_;
2552 } 2553 }
2553 2554
2554 IN_PROC_BROWSER_TEST_P(WebViewTest, DownloadPermission) { 2555 IN_PROC_BROWSER_TEST_P(WebViewTest, DownloadPermission) {
2555 ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages. 2556 ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages.
2556 content::WebContents* guest_web_contents = 2557 content::WebContents* guest_web_contents =
2557 LoadGuest("/extensions/platform_apps/web_view/download/guest.html", 2558 LoadGuest("/extensions/platform_apps/web_view/download/guest.html",
2558 "web_view/download"); 2559 "web_view/download");
2559 ASSERT_TRUE(guest_web_contents); 2560 ASSERT_TRUE(guest_web_contents);
2560 2561
2562 base::ThreadRestrictions::ScopedAllowIO allow_io;
2561 base::ScopedTempDir temporary_download_dir; 2563 base::ScopedTempDir temporary_download_dir;
2562 ASSERT_TRUE(temporary_download_dir.CreateUniqueTempDir()); 2564 ASSERT_TRUE(temporary_download_dir.CreateUniqueTempDir());
2563 DownloadPrefs::FromBrowserContext(guest_web_contents->GetBrowserContext()) 2565 DownloadPrefs::FromBrowserContext(guest_web_contents->GetBrowserContext())
2564 ->SetDownloadPath(temporary_download_dir.GetPath()); 2566 ->SetDownloadPath(temporary_download_dir.GetPath());
2565 2567
2566 std::unique_ptr<content::DownloadTestObserver> completion_observer( 2568 std::unique_ptr<content::DownloadTestObserver> completion_observer(
2567 new content::DownloadTestObserverTerminal( 2569 new content::DownloadTestObserverTerminal(
2568 content::BrowserContext::GetDownloadManager( 2570 content::BrowserContext::GetDownloadManager(
2569 guest_web_contents->GetBrowserContext()), 2571 guest_web_contents->GetBrowserContext()),
2570 1, content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL)); 2572 1, content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL));
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
2708 2710
2709 embedded_test_server()->RegisterRequestHandler( 2711 embedded_test_server()->RegisterRequestHandler(
2710 base::Bind(&HandleDownloadRequestWithCookie, &status_codes)); 2712 base::Bind(&HandleDownloadRequestWithCookie, &status_codes));
2711 ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages. 2713 ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages.
2712 LoadAndLaunchPlatformApp("web_view/download_cookie_isolation", 2714 LoadAndLaunchPlatformApp("web_view/download_cookie_isolation",
2713 "created-webviews"); 2715 "created-webviews");
2714 2716
2715 content::WebContents* web_contents = GetFirstAppWindowWebContents(); 2717 content::WebContents* web_contents = GetFirstAppWindowWebContents();
2716 ASSERT_TRUE(web_contents); 2718 ASSERT_TRUE(web_contents);
2717 2719
2720 base::ThreadRestrictions::ScopedAllowIO allow_io;
2718 base::ScopedTempDir temporary_download_dir; 2721 base::ScopedTempDir temporary_download_dir;
2719 ASSERT_TRUE(temporary_download_dir.CreateUniqueTempDir()); 2722 ASSERT_TRUE(temporary_download_dir.CreateUniqueTempDir());
2720 DownloadPrefs::FromBrowserContext(web_contents->GetBrowserContext()) 2723 DownloadPrefs::FromBrowserContext(web_contents->GetBrowserContext())
2721 ->SetDownloadPath(temporary_download_dir.GetPath()); 2724 ->SetDownloadPath(temporary_download_dir.GetPath());
2722 2725
2723 content::DownloadManager* download_manager = 2726 content::DownloadManager* download_manager =
2724 content::BrowserContext::GetDownloadManager( 2727 content::BrowserContext::GetDownloadManager(
2725 web_contents->GetBrowserContext()); 2728 web_contents->GetBrowserContext());
2726 2729
2727 std::unique_ptr<content::DownloadTestObserver> interrupted_observer( 2730 std::unique_ptr<content::DownloadTestObserver> interrupted_observer(
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
2793 2796
2794 embedded_test_server()->RegisterRequestHandler( 2797 embedded_test_server()->RegisterRequestHandler(
2795 base::Bind(&HandleDownloadRequestWithCookie, &status_codes)); 2798 base::Bind(&HandleDownloadRequestWithCookie, &status_codes));
2796 ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages. 2799 ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages.
2797 LoadAndLaunchPlatformApp("web_view/download_cookie_isolation", 2800 LoadAndLaunchPlatformApp("web_view/download_cookie_isolation",
2798 "created-webviews"); 2801 "created-webviews");
2799 2802
2800 content::WebContents* web_contents = GetFirstAppWindowWebContents(); 2803 content::WebContents* web_contents = GetFirstAppWindowWebContents();
2801 ASSERT_TRUE(web_contents); 2804 ASSERT_TRUE(web_contents);
2802 2805
2806 base::ThreadRestrictions::ScopedAllowIO allow_io;
2803 base::ScopedTempDir temporary_download_dir; 2807 base::ScopedTempDir temporary_download_dir;
2804 ASSERT_TRUE(temporary_download_dir.CreateUniqueTempDir()); 2808 ASSERT_TRUE(temporary_download_dir.CreateUniqueTempDir());
2805 DownloadPrefs::FromBrowserContext(web_contents->GetBrowserContext()) 2809 DownloadPrefs::FromBrowserContext(web_contents->GetBrowserContext())
2806 ->SetDownloadPath(temporary_download_dir.GetPath()); 2810 ->SetDownloadPath(temporary_download_dir.GetPath());
2807 2811
2808 content::DownloadManager* download_manager = 2812 content::DownloadManager* download_manager =
2809 content::BrowserContext::GetDownloadManager( 2813 content::BrowserContext::GetDownloadManager(
2810 web_contents->GetBrowserContext()); 2814 web_contents->GetBrowserContext());
2811 2815
2812 DownloadHistoryWaiter history_waiter(web_contents->GetBrowserContext()); 2816 DownloadHistoryWaiter history_waiter(web_contents->GetBrowserContext());
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2851 base::Bind(&HandleDownloadRequestWithCookie, &status_codes)); 2855 base::Bind(&HandleDownloadRequestWithCookie, &status_codes));
2852 ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages. 2856 ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages.
2853 2857
2854 content::BrowserContext* browser_context = profile(); 2858 content::BrowserContext* browser_context = profile();
2855 content::DownloadManager* download_manager = 2859 content::DownloadManager* download_manager =
2856 content::BrowserContext::GetDownloadManager(browser_context); 2860 content::BrowserContext::GetDownloadManager(browser_context);
2857 2861
2858 DownloadHistoryWaiter history_waiter(browser_context); 2862 DownloadHistoryWaiter history_waiter(browser_context);
2859 history_waiter.WaitForHistoryLoad(); 2863 history_waiter.WaitForHistoryLoad();
2860 2864
2865 base::ThreadRestrictions::ScopedAllowIO allow_io;
2861 base::ScopedTempDir temporary_download_dir; 2866 base::ScopedTempDir temporary_download_dir;
2862 ASSERT_TRUE(temporary_download_dir.Set( 2867 ASSERT_TRUE(temporary_download_dir.Set(
2863 DownloadPrefs::FromBrowserContext(browser_context)->DownloadPath())); 2868 DownloadPrefs::FromBrowserContext(browser_context)->DownloadPath()));
2864 2869
2865 content::DownloadManager::DownloadVector saved_downloads; 2870 content::DownloadManager::DownloadVector saved_downloads;
2866 download_manager->GetAllDownloads(&saved_downloads); 2871 download_manager->GetAllDownloads(&saved_downloads);
2867 ASSERT_EQ(2u, saved_downloads.size()); 2872 ASSERT_EQ(2u, saved_downloads.size());
2868 2873
2869 content::DownloadManager::DownloadVector downloads; 2874 content::DownloadManager::DownloadVector downloads;
2870 // We can't trivially resume the previous downloads because they are going to 2875 // We can't trivially resume the previous downloads because they are going to
(...skipping 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after
4131 ClosingChromeSignInShouldNotCrash) { 4136 ClosingChromeSignInShouldNotCrash) {
4132 GURL signin_url{"chrome://chrome-signin"}; 4137 GURL signin_url{"chrome://chrome-signin"};
4133 4138
4134 AddTabAtIndex(0, signin_url, ui::PAGE_TRANSITION_TYPED); 4139 AddTabAtIndex(0, signin_url, ui::PAGE_TRANSITION_TYPED);
4135 AddTabAtIndex(1, signin_url, ui::PAGE_TRANSITION_TYPED); 4140 AddTabAtIndex(1, signin_url, ui::PAGE_TRANSITION_TYPED);
4136 WaitForWebViewInDom(); 4141 WaitForWebViewInDom();
4137 4142
4138 chrome::CloseTab(browser()); 4143 chrome::CloseTab(browser());
4139 } 4144 }
4140 #endif 4145 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698