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

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

Issue 10879018: Convert the Web SQL Database pyauto test to content_browsertests. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 4 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
« no previous file with comments | « no previous file | chrome/test/data/database/database_tester.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
6 #include "base/path_service.h"
5 #include "chrome/browser/browsing_data/browsing_data_helper.h" 7 #include "chrome/browser/browsing_data/browsing_data_helper.h"
6 #include "chrome/browser/browsing_data/browsing_data_remover.h" 8 #include "chrome/browser/browsing_data/browsing_data_remover.h"
7 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/browser_tabstrip.h" 11 #include "chrome/browser/ui/browser_tabstrip.h"
10 #include "chrome/common/chrome_notification_types.h" 12 #include "chrome/common/chrome_notification_types.h"
11 #include "chrome/test/base/in_process_browser_test.h" 13 #include "chrome/test/base/in_process_browser_test.h"
12 #include "chrome/test/base/ui_test_utils.h" 14 #include "chrome/test/base/ui_test_utils.h"
13 #include "content/public/browser/browser_context.h" 15 #include "content/public/browser/browser_context.h"
16 #include "content/public/browser/browser_thread.h"
14 #include "content/public/browser/download_manager.h" 17 #include "content/public/browser/download_manager.h"
15 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
19 #include "content/public/common/content_paths.h"
16 #include "content/public/test/browser_test_utils.h" 20 #include "content/public/test/browser_test_utils.h"
17 #include "content/public/test/download_test_observer.h" 21 #include "content/public/test/download_test_observer.h"
18 #include "content/test/net/url_request_mock_http_job.h" 22 #include "content/test/net/url_request_mock_http_job.h"
19 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
20 24
25 using content::BrowserThread;
26
27 namespace {
28 void SetUrlRequestMock(const FilePath& path) {
29 URLRequestMockHTTPJob::AddUrlHandler(path);
30 }
31 }
32
21 class BrowsingDataRemoverBrowserTest : public InProcessBrowserTest { 33 class BrowsingDataRemoverBrowserTest : public InProcessBrowserTest {
22 public: 34 public:
23 BrowsingDataRemoverBrowserTest() {} 35 BrowsingDataRemoverBrowserTest() {}
24 36
37 virtual void SetUpOnMainThread() OVERRIDE {
38 FilePath path;
39 PathService::Get(content::DIR_TEST_DATA, &path);
40 BrowserThread::PostTask(
41 BrowserThread::IO, FROM_HERE, base::Bind(&SetUrlRequestMock, path));
42 }
43
25 void RunScriptAndCheckResult(const std::wstring& script, 44 void RunScriptAndCheckResult(const std::wstring& script,
26 const std::string& result) { 45 const std::string& result) {
27 std::string data; 46 std::string data;
28 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString( 47 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString(
29 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), L"", 48 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), L"",
30 script, &data)); 49 script, &data));
31 ASSERT_EQ(data, result); 50 ASSERT_EQ(data, result);
32 } 51 }
33 52
34 void RemoveAndWait(int remove_mask) { 53 void RemoveAndWait(int remove_mask) {
(...skipping 30 matching lines...) Expand all
65 84
66 RemoveAndWait(BrowsingDataRemover::REMOVE_DOWNLOADS); 85 RemoveAndWait(BrowsingDataRemover::REMOVE_DOWNLOADS);
67 86
68 downloads.clear(); 87 downloads.clear();
69 download_manager->GetAllDownloads(FilePath(), &downloads); 88 download_manager->GetAllDownloads(FilePath(), &downloads);
70 EXPECT_TRUE(downloads.empty()); 89 EXPECT_TRUE(downloads.empty());
71 } 90 }
72 91
73 // Verify can modify database after deleting it. 92 // Verify can modify database after deleting it.
74 IN_PROC_BROWSER_TEST_F(BrowsingDataRemoverBrowserTest, Database) { 93 IN_PROC_BROWSER_TEST_F(BrowsingDataRemoverBrowserTest, Database) {
75 ASSERT_TRUE(test_server()->Start()); 94 GURL url(URLRequestMockHTTPJob::GetMockUrl(
76 GURL url = test_server()->GetURL("files/database/simple_database.html"); 95 FilePath().AppendASCII("simple_database.html")));
77 ui_test_utils::NavigateToURL(browser(), url); 96 ui_test_utils::NavigateToURL(browser(), url);
78 97
79 RunScriptAndCheckResult(L"createTable()", "done"); 98 RunScriptAndCheckResult(L"createTable()", "done");
80 RunScriptAndCheckResult(L"insertRecord('text')", "done"); 99 RunScriptAndCheckResult(L"insertRecord('text')", "done");
81 RunScriptAndCheckResult(L"getRecords()", "text"); 100 RunScriptAndCheckResult(L"getRecords()", "text");
82 101
83 RemoveAndWait(BrowsingDataRemover::REMOVE_SITE_DATA); 102 RemoveAndWait(BrowsingDataRemover::REMOVE_SITE_DATA);
84 103
85 ui_test_utils::NavigateToURL(browser(), url); 104 ui_test_utils::NavigateToURL(browser(), url);
86 RunScriptAndCheckResult(L"createTable()", "done"); 105 RunScriptAndCheckResult(L"createTable()", "done");
87 RunScriptAndCheckResult(L"insertRecord('text2')", "done"); 106 RunScriptAndCheckResult(L"insertRecord('text2')", "done");
88 RunScriptAndCheckResult(L"getRecords()", "text2"); 107 RunScriptAndCheckResult(L"getRecords()", "text2");
89 } 108 }
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/database/database_tester.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698