| 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/file_path.h" | 5 #include "base/file_path.h" |
| 6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
| 7 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 7 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 8 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 8 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
| 9 #include "chrome/browser/prefs/pref_service.h" | 9 #include "chrome/browser/prefs/pref_service.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 public: | 36 public: |
| 37 BrowsingDataRemoverBrowserTest() {} | 37 BrowsingDataRemoverBrowserTest() {} |
| 38 | 38 |
| 39 virtual void SetUpOnMainThread() OVERRIDE { | 39 virtual void SetUpOnMainThread() OVERRIDE { |
| 40 FilePath path; | 40 FilePath path; |
| 41 PathService::Get(content::DIR_TEST_DATA, &path); | 41 PathService::Get(content::DIR_TEST_DATA, &path); |
| 42 BrowserThread::PostTask( | 42 BrowserThread::PostTask( |
| 43 BrowserThread::IO, FROM_HERE, base::Bind(&SetUrlRequestMock, path)); | 43 BrowserThread::IO, FROM_HERE, base::Bind(&SetUrlRequestMock, path)); |
| 44 } | 44 } |
| 45 | 45 |
| 46 void RunScriptAndCheckResult(const std::string& script, | 46 void RunScriptAndCheckResult(const std::wstring& script, |
| 47 const std::string& result) { | 47 const std::string& result) { |
| 48 std::string data; | 48 std::string data; |
| 49 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString( | 49 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString( |
| 50 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), | 50 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), L"", |
| 51 "", | 51 script, &data)); |
| 52 script, | |
| 53 &data)); | |
| 54 ASSERT_EQ(data, result); | 52 ASSERT_EQ(data, result); |
| 55 } | 53 } |
| 56 | 54 |
| 57 void RemoveAndWait(int remove_mask) { | 55 void RemoveAndWait(int remove_mask) { |
| 58 content::WindowedNotificationObserver signal( | 56 content::WindowedNotificationObserver signal( |
| 59 chrome::NOTIFICATION_BROWSING_DATA_REMOVED, | 57 chrome::NOTIFICATION_BROWSING_DATA_REMOVED, |
| 60 content::Source<Profile>(browser()->profile())); | 58 content::Source<Profile>(browser()->profile())); |
| 61 BrowsingDataRemover* remover = BrowsingDataRemover::CreateForPeriod( | 59 BrowsingDataRemover* remover = BrowsingDataRemover::CreateForPeriod( |
| 62 browser()->profile(), BrowsingDataRemover::LAST_HOUR); | 60 browser()->profile(), BrowsingDataRemover::LAST_HOUR); |
| 63 remover->Remove(remove_mask, BrowsingDataHelper::UNPROTECTED_WEB); | 61 remover->Remove(remove_mask, BrowsingDataHelper::UNPROTECTED_WEB); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 download_manager->GetAllDownloads(&downloads); | 94 download_manager->GetAllDownloads(&downloads); |
| 97 EXPECT_TRUE(downloads.empty()); | 95 EXPECT_TRUE(downloads.empty()); |
| 98 } | 96 } |
| 99 | 97 |
| 100 // Verify can modify database after deleting it. | 98 // Verify can modify database after deleting it. |
| 101 IN_PROC_BROWSER_TEST_F(BrowsingDataRemoverBrowserTest, Database) { | 99 IN_PROC_BROWSER_TEST_F(BrowsingDataRemoverBrowserTest, Database) { |
| 102 GURL url(content::URLRequestMockHTTPJob::GetMockUrl( | 100 GURL url(content::URLRequestMockHTTPJob::GetMockUrl( |
| 103 FilePath().AppendASCII("simple_database.html"))); | 101 FilePath().AppendASCII("simple_database.html"))); |
| 104 ui_test_utils::NavigateToURL(browser(), url); | 102 ui_test_utils::NavigateToURL(browser(), url); |
| 105 | 103 |
| 106 RunScriptAndCheckResult("createTable()", "done"); | 104 RunScriptAndCheckResult(L"createTable()", "done"); |
| 107 RunScriptAndCheckResult("insertRecord('text')", "done"); | 105 RunScriptAndCheckResult(L"insertRecord('text')", "done"); |
| 108 RunScriptAndCheckResult("getRecords()", "text"); | 106 RunScriptAndCheckResult(L"getRecords()", "text"); |
| 109 | 107 |
| 110 RemoveAndWait(BrowsingDataRemover::REMOVE_SITE_DATA); | 108 RemoveAndWait(BrowsingDataRemover::REMOVE_SITE_DATA); |
| 111 | 109 |
| 112 ui_test_utils::NavigateToURL(browser(), url); | 110 ui_test_utils::NavigateToURL(browser(), url); |
| 113 RunScriptAndCheckResult("createTable()", "done"); | 111 RunScriptAndCheckResult(L"createTable()", "done"); |
| 114 RunScriptAndCheckResult("insertRecord('text2')", "done"); | 112 RunScriptAndCheckResult(L"insertRecord('text2')", "done"); |
| 115 RunScriptAndCheckResult("getRecords()", "text2"); | 113 RunScriptAndCheckResult(L"getRecords()", "text2"); |
| 116 } | 114 } |
| 117 | 115 |
| 118 // Profile::ClearNetworkingHistorySince should be exercised here too see whether | 116 // Profile::ClearNetworkingHistorySince should be exercised here too see whether |
| 119 // the call gets delegated through ProfileIO[Impl]Data properly, which is hard | 117 // the call gets delegated through ProfileIO[Impl]Data properly, which is hard |
| 120 // to write unit-tests for. Currently this is done by both of the above tests. | 118 // to write unit-tests for. Currently this is done by both of the above tests. |
| 121 // Add standalone test if this changes. | 119 // Add standalone test if this changes. |
| OLD | NEW |