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 "base/files/file_path.h" | 5 #include "base/files/file_path.h" |
6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 8 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
9 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 9 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
10 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" | 10 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" |
11 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
14 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
15 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
16 #include "chrome/test/base/in_process_browser_test.h" | 16 #include "chrome/test/base/in_process_browser_test.h" |
17 #include "chrome/test/base/ui_test_utils.h" | 17 #include "chrome/test/base/ui_test_utils.h" |
18 #include "content/public/browser/browser_context.h" | 18 #include "content/public/browser/browser_context.h" |
19 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
20 #include "content/public/browser/download_manager.h" | 20 #include "content/public/browser/download_manager.h" |
21 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
22 #include "content/public/common/content_paths.h" | 22 #include "content/public/common/content_paths.h" |
23 #include "content/public/test/browser_test_utils.h" | 23 #include "content/public/test/browser_test_utils.h" |
24 #include "content/public/test/download_test_observer.h" | 24 #include "content/public/test/download_test_observer.h" |
25 #include "content/test/net/url_request_mock_http_job.h" | 25 #include "net/test/url_request/url_request_mock_http_job.h" |
26 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
27 | 27 |
28 using content::BrowserThread; | 28 using content::BrowserThread; |
29 | 29 |
30 namespace { | 30 namespace { |
31 void SetUrlRequestMock(const base::FilePath& path) { | 31 void SetUrlRequestMock(const base::FilePath& path) { |
32 content::URLRequestMockHTTPJob::AddUrlHandler(path); | 32 net::URLRequestMockHTTPJob::AddUrlHandler( |
| 33 path, |
| 34 content::BrowserThread::GetBlockingPool()); |
33 } | 35 } |
34 } | 36 } |
35 | 37 |
36 class BrowsingDataRemoverBrowserTest : public InProcessBrowserTest { | 38 class BrowsingDataRemoverBrowserTest : public InProcessBrowserTest { |
37 public: | 39 public: |
38 BrowsingDataRemoverBrowserTest() {} | 40 BrowsingDataRemoverBrowserTest() {} |
39 | 41 |
40 virtual void SetUpOnMainThread() OVERRIDE { | 42 virtual void SetUpOnMainThread() OVERRIDE { |
41 base::FilePath path; | 43 base::FilePath path; |
42 PathService::Get(content::DIR_TEST_DATA, &path); | 44 PathService::Get(content::DIR_TEST_DATA, &path); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 prefs->SetBoolean(prefs::kAllowDeletingBrowserHistory, false); | 111 prefs->SetBoolean(prefs::kAllowDeletingBrowserHistory, false); |
110 | 112 |
111 DownloadAnItem(); | 113 DownloadAnItem(); |
112 RemoveAndWait(BrowsingDataRemover::REMOVE_DOWNLOADS); | 114 RemoveAndWait(BrowsingDataRemover::REMOVE_DOWNLOADS); |
113 VerifyDownloadCount(1u); | 115 VerifyDownloadCount(1u); |
114 } | 116 } |
115 #endif | 117 #endif |
116 | 118 |
117 // Verify can modify database after deleting it. | 119 // Verify can modify database after deleting it. |
118 IN_PROC_BROWSER_TEST_F(BrowsingDataRemoverBrowserTest, Database) { | 120 IN_PROC_BROWSER_TEST_F(BrowsingDataRemoverBrowserTest, Database) { |
119 GURL url(content::URLRequestMockHTTPJob::GetMockUrl( | 121 GURL url(net::URLRequestMockHTTPJob::GetMockUrl( |
120 base::FilePath().AppendASCII("simple_database.html"))); | 122 base::FilePath().AppendASCII("simple_database.html"))); |
121 ui_test_utils::NavigateToURL(browser(), url); | 123 ui_test_utils::NavigateToURL(browser(), url); |
122 | 124 |
123 RunScriptAndCheckResult("createTable()", "done"); | 125 RunScriptAndCheckResult("createTable()", "done"); |
124 RunScriptAndCheckResult("insertRecord('text')", "done"); | 126 RunScriptAndCheckResult("insertRecord('text')", "done"); |
125 RunScriptAndCheckResult("getRecords()", "text"); | 127 RunScriptAndCheckResult("getRecords()", "text"); |
126 | 128 |
127 RemoveAndWait(BrowsingDataRemover::REMOVE_SITE_DATA); | 129 RemoveAndWait(BrowsingDataRemover::REMOVE_SITE_DATA); |
128 | 130 |
129 ui_test_utils::NavigateToURL(browser(), url); | 131 ui_test_utils::NavigateToURL(browser(), url); |
130 RunScriptAndCheckResult("createTable()", "done"); | 132 RunScriptAndCheckResult("createTable()", "done"); |
131 RunScriptAndCheckResult("insertRecord('text2')", "done"); | 133 RunScriptAndCheckResult("insertRecord('text2')", "done"); |
132 RunScriptAndCheckResult("getRecords()", "text2"); | 134 RunScriptAndCheckResult("getRecords()", "text2"); |
133 } | 135 } |
134 | 136 |
135 // Profile::ClearNetworkingHistorySince should be exercised here too see whether | 137 // Profile::ClearNetworkingHistorySince should be exercised here too see whether |
136 // the call gets delegated through ProfileIO[Impl]Data properly, which is hard | 138 // the call gets delegated through ProfileIO[Impl]Data properly, which is hard |
137 // to write unit-tests for. Currently this is done by both of the above tests. | 139 // to write unit-tests for. Currently this is done by both of the above tests. |
138 // Add standalone test if this changes. | 140 // Add standalone test if this changes. |
OLD | NEW |