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

Side by Side Diff: chrome/browser/browsing_data/browsing_data_remover_browsertest.cc

Issue 11728003: Change ExecuteJavaScript* helper functions in browser_test_utils.{h,cc} (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adding files for gpu_tests and NaCl browser tests. Created 7 years, 11 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 | Annotate | Revision Log
OLDNEW
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
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::wstring& script, 46 void RunScriptAndCheckResult(const std::string& 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(), L"", 50 chrome::GetActiveWebContents(browser())->GetRenderViewHost(),
51 script, &data)); 51 "",
52 script,
53 &data));
52 ASSERT_EQ(data, result); 54 ASSERT_EQ(data, result);
53 } 55 }
54 56
55 void RemoveAndWait(int remove_mask) { 57 void RemoveAndWait(int remove_mask) {
56 content::WindowedNotificationObserver signal( 58 content::WindowedNotificationObserver signal(
57 chrome::NOTIFICATION_BROWSING_DATA_REMOVED, 59 chrome::NOTIFICATION_BROWSING_DATA_REMOVED,
58 content::Source<Profile>(browser()->profile())); 60 content::Source<Profile>(browser()->profile()));
59 BrowsingDataRemover* remover = BrowsingDataRemover::CreateForPeriod( 61 BrowsingDataRemover* remover = BrowsingDataRemover::CreateForPeriod(
60 browser()->profile(), BrowsingDataRemover::LAST_HOUR); 62 browser()->profile(), BrowsingDataRemover::LAST_HOUR);
61 remover->Remove(remove_mask, BrowsingDataHelper::UNPROTECTED_WEB); 63 remover->Remove(remove_mask, BrowsingDataHelper::UNPROTECTED_WEB);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 download_manager->GetAllDownloads(&downloads); 96 download_manager->GetAllDownloads(&downloads);
95 EXPECT_TRUE(downloads.empty()); 97 EXPECT_TRUE(downloads.empty());
96 } 98 }
97 99
98 // Verify can modify database after deleting it. 100 // Verify can modify database after deleting it.
99 IN_PROC_BROWSER_TEST_F(BrowsingDataRemoverBrowserTest, Database) { 101 IN_PROC_BROWSER_TEST_F(BrowsingDataRemoverBrowserTest, Database) {
100 GURL url(content::URLRequestMockHTTPJob::GetMockUrl( 102 GURL url(content::URLRequestMockHTTPJob::GetMockUrl(
101 FilePath().AppendASCII("simple_database.html"))); 103 FilePath().AppendASCII("simple_database.html")));
102 ui_test_utils::NavigateToURL(browser(), url); 104 ui_test_utils::NavigateToURL(browser(), url);
103 105
104 RunScriptAndCheckResult(L"createTable()", "done"); 106 RunScriptAndCheckResult("createTable()", "done");
105 RunScriptAndCheckResult(L"insertRecord('text')", "done"); 107 RunScriptAndCheckResult("insertRecord('text')", "done");
106 RunScriptAndCheckResult(L"getRecords()", "text"); 108 RunScriptAndCheckResult("getRecords()", "text");
107 109
108 RemoveAndWait(BrowsingDataRemover::REMOVE_SITE_DATA); 110 RemoveAndWait(BrowsingDataRemover::REMOVE_SITE_DATA);
109 111
110 ui_test_utils::NavigateToURL(browser(), url); 112 ui_test_utils::NavigateToURL(browser(), url);
111 RunScriptAndCheckResult(L"createTable()", "done"); 113 RunScriptAndCheckResult("createTable()", "done");
112 RunScriptAndCheckResult(L"insertRecord('text2')", "done"); 114 RunScriptAndCheckResult("insertRecord('text2')", "done");
113 RunScriptAndCheckResult(L"getRecords()", "text2"); 115 RunScriptAndCheckResult("getRecords()", "text2");
114 } 116 }
115 117
116 // Profile::ClearNetworkingHistorySince should be exercised here too see whether 118 // Profile::ClearNetworkingHistorySince should be exercised here too see whether
117 // the call gets delegated through ProfileIO[Impl]Data properly, which is hard 119 // the call gets delegated through ProfileIO[Impl]Data properly, which is hard
118 // to write unit-tests for. Currently this is done by both of the above tests. 120 // to write unit-tests for. Currently this is done by both of the above tests.
119 // Add standalone test if this changes. 121 // Add standalone test if this changes.
OLDNEW
« no previous file with comments | « chrome/browser/browser_keyevents_browsertest.cc ('k') | chrome/browser/chrome_switches_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698