OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <sstream> | 5 #include <sstream> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 #include "chrome/browser/ui/browser_commands.h" | 47 #include "chrome/browser/ui/browser_commands.h" |
48 #include "chrome/browser/ui/browser_finder.h" | 48 #include "chrome/browser/ui/browser_finder.h" |
49 #include "chrome/browser/ui/browser_list.h" | 49 #include "chrome/browser/ui/browser_list.h" |
50 #include "chrome/browser/ui/browser_tabstrip.h" | 50 #include "chrome/browser/ui/browser_tabstrip.h" |
51 #include "chrome/browser/ui/browser_window.h" | 51 #include "chrome/browser/ui/browser_window.h" |
52 #include "chrome/browser/ui/chrome_pages.h" | 52 #include "chrome/browser/ui/chrome_pages.h" |
53 #include "chrome/browser/ui/host_desktop.h" | 53 #include "chrome/browser/ui/host_desktop.h" |
54 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 54 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
55 #include "chrome/common/chrome_notification_types.h" | 55 #include "chrome/common/chrome_notification_types.h" |
56 #include "chrome/common/chrome_paths.h" | 56 #include "chrome/common/chrome_paths.h" |
| 57 #include "chrome/common/extensions/api/requirements/requirements_handler.h" |
57 #include "chrome/common/extensions/feature_switch.h" | 58 #include "chrome/common/extensions/feature_switch.h" |
| 59 #include "chrome/common/extensions/manifest_handler.h" |
58 #include "chrome/common/pref_names.h" | 60 #include "chrome/common/pref_names.h" |
59 #include "chrome/common/url_constants.h" | 61 #include "chrome/common/url_constants.h" |
60 #include "chrome/test/base/in_process_browser_test.h" | 62 #include "chrome/test/base/in_process_browser_test.h" |
61 #include "chrome/test/base/ui_test_utils.h" | 63 #include "chrome/test/base/ui_test_utils.h" |
62 #include "content/public/browser/download_item.h" | 64 #include "content/public/browser/download_item.h" |
63 #include "content/public/browser/download_manager.h" | 65 #include "content/public/browser/download_manager.h" |
64 #include "content/public/browser/download_save_info.h" | 66 #include "content/public/browser/download_save_info.h" |
65 #include "content/public/browser/download_url_parameters.h" | 67 #include "content/public/browser/download_url_parameters.h" |
66 #include "content/public/browser/notification_source.h" | 68 #include "content/public/browser/notification_source.h" |
67 #include "content/public/browser/plugin_service.h" | 69 #include "content/public/browser/plugin_service.h" |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 }; | 395 }; |
394 | 396 |
395 struct FileErrorInjectInfo { | 397 struct FileErrorInjectInfo { |
396 DownloadInfo download_info; | 398 DownloadInfo download_info; |
397 content::TestFileErrorInjector::FileErrorInfo error_info; | 399 content::TestFileErrorInjector::FileErrorInfo error_info; |
398 }; | 400 }; |
399 | 401 |
400 DownloadTest() {} | 402 DownloadTest() {} |
401 | 403 |
402 virtual void SetUpOnMainThread() OVERRIDE { | 404 virtual void SetUpOnMainThread() OVERRIDE { |
| 405 InProcessBrowserTest::SetUpOnMainThread(); |
403 BrowserThread::PostTask( | 406 BrowserThread::PostTask( |
404 BrowserThread::IO, FROM_HERE, | 407 BrowserThread::IO, FROM_HERE, |
405 base::Bind(&chrome_browser_net::SetUrlRequestMocksEnabled, true)); | 408 base::Bind(&chrome_browser_net::SetUrlRequestMocksEnabled, true)); |
406 ASSERT_TRUE(InitialSetup()); | 409 ASSERT_TRUE(InitialSetup()); |
| 410 (new extensions::RequirementsHandler)->Register(); |
407 } | 411 } |
408 | 412 |
409 virtual void CleanUpOnMainThread() OVERRIDE { | 413 virtual void CleanUpOnMainThread() OVERRIDE { |
410 // Needs to be torn down on the main thread. file_activity_observer_ holds a | 414 // Needs to be torn down on the main thread. file_activity_observer_ holds a |
411 // reference to the ChromeDownloadManagerDelegate which should be destroyed | 415 // reference to the ChromeDownloadManagerDelegate which should be destroyed |
412 // on the UI thread. | 416 // on the UI thread. |
413 file_activity_observer_.reset(); | 417 file_activity_observer_.reset(); |
| 418 |
| 419 extensions::ManifestHandler::ClearRegistryForTesting(); |
| 420 InProcessBrowserTest::CleanUpOnMainThread(); |
414 } | 421 } |
415 | 422 |
416 // Returning false indicates a failure of the setup, and should be asserted | 423 // Returning false indicates a failure of the setup, and should be asserted |
417 // in the caller. | 424 // in the caller. |
418 virtual bool InitialSetup() { | 425 virtual bool InitialSetup() { |
419 bool have_test_dir = PathService::Get(chrome::DIR_TEST_DATA, &test_dir_); | 426 bool have_test_dir = PathService::Get(chrome::DIR_TEST_DATA, &test_dir_); |
420 EXPECT_TRUE(have_test_dir); | 427 EXPECT_TRUE(have_test_dir); |
421 if (!have_test_dir) | 428 if (!have_test_dir) |
422 return false; | 429 return false; |
423 | 430 |
(...skipping 2498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2922 scoped_ptr<content::DownloadTestObserver> observer( | 2929 scoped_ptr<content::DownloadTestObserver> observer( |
2923 DangerousDownloadWaiter( | 2930 DangerousDownloadWaiter( |
2924 browser(), 1, | 2931 browser(), 1, |
2925 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY)); | 2932 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY)); |
2926 ui_test_utils::NavigateToURL(browser(), url); | 2933 ui_test_utils::NavigateToURL(browser(), url); |
2927 observer->WaitForFinished(); | 2934 observer->WaitForFinished(); |
2928 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::CANCELLED)); | 2935 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::CANCELLED)); |
2929 EXPECT_EQ(1u, observer->NumDangerousDownloadsSeen()); | 2936 EXPECT_EQ(1u, observer->NumDangerousDownloadsSeen()); |
2930 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); | 2937 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); |
2931 } | 2938 } |
OLD | NEW |