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

Side by Side Diff: content/browser/dom_storage/dom_storage_browsertest.cc

Issue 10795090: Move ExecuteJavaScript functions from ui_test_utils.h to browser_test_utils.h so they can be reused… (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
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/path_service.h" 5 #include "base/path_service.h"
6 #include "chrome/browser/ui/browser.h" 6 #include "chrome/browser/ui/browser.h"
7 #include "chrome/browser/ui/browser_tabstrip.h" 7 #include "chrome/browser/ui/browser_tabstrip.h"
8 #include "chrome/test/base/in_process_browser_test.h" 8 #include "chrome/test/base/in_process_browser_test.h"
9 #include "chrome/test/base/ui_test_utils.h" 9 #include "chrome/test/base/ui_test_utils.h"
10 #include "content/browser/web_contents/web_contents_impl.h" 10 #include "content/browser/web_contents/web_contents_impl.h"
11 #include "content/public/common/content_paths.h" 11 #include "content/public/common/content_paths.h"
12 #include "content/public/test/browser_test_utils.h"
12 #include "net/base/net_util.h" 13 #include "net/base/net_util.h"
13 #include "webkit/dom_storage/dom_storage_types.h" 14 #include "webkit/dom_storage/dom_storage_types.h"
14 15
15 // This browser test is aimed towards exercising the DomStorage system 16 // This browser test is aimed towards exercising the DomStorage system
16 // from end-to-end. 17 // from end-to-end.
17 class DomStorageBrowserTest : public InProcessBrowserTest { 18 class DomStorageBrowserTest : public InProcessBrowserTest {
18 public: 19 public:
19 DomStorageBrowserTest() {} 20 DomStorageBrowserTest() {}
20 21
21 GURL GetTestURL(const char* name) { 22 GURL GetTestURL(const char* name) {
22 FilePath file_name = FilePath().AppendASCII(name); 23 FilePath file_name = FilePath().AppendASCII(name);
23 FilePath dir; 24 FilePath dir;
24 PathService::Get(content::DIR_TEST_DATA, &dir); 25 PathService::Get(content::DIR_TEST_DATA, &dir);
25 return net::FilePathToFileURL( 26 return net::FilePathToFileURL(
26 dir.Append(FILE_PATH_LITERAL("dom_storage")).Append(file_name)); 27 dir.Append(FILE_PATH_LITERAL("dom_storage")).Append(file_name));
27 } 28 }
28 29
29 void SimpleTest(const GURL& test_url, bool incognito) { 30 void SimpleTest(const GURL& test_url, bool incognito) {
30 // The test page will perform tests then navigate to either 31 // The test page will perform tests then navigate to either
31 // a #pass or #fail ref. 32 // a #pass or #fail ref.
32 Browser* the_browser = incognito ? CreateIncognitoBrowser() : browser(); 33 Browser* the_browser = incognito ? CreateIncognitoBrowser() : browser();
33 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( 34 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
34 the_browser, test_url, 2); 35 the_browser, test_url, 2);
35 std::string result = 36 std::string result =
36 chrome::GetActiveWebContents(the_browser)->GetURL().ref(); 37 chrome::GetActiveWebContents(the_browser)->GetURL().ref();
37 if (result != "pass") { 38 if (result != "pass") {
38 std::string js_result; 39 std::string js_result;
39 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString( 40 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString(
40 chrome::GetActiveWebContents(the_browser)->GetRenderViewHost(), L"", 41 chrome::GetActiveWebContents(the_browser)->GetRenderViewHost(), L"",
41 L"window.domAutomationController.send(getLog())", &js_result)); 42 L"window.domAutomationController.send(getLog())", &js_result));
42 FAIL() << "Failed: " << js_result; 43 FAIL() << "Failed: " << js_result;
43 } 44 }
44 } 45 }
45 }; 46 };
46 47
47 static const bool kIncognito = true; 48 static const bool kIncognito = true;
48 static const bool kNotIncognito = false; 49 static const bool kNotIncognito = false;
49 50
50 IN_PROC_BROWSER_TEST_F(DomStorageBrowserTest, SanityCheck) { 51 IN_PROC_BROWSER_TEST_F(DomStorageBrowserTest, SanityCheck) {
51 SimpleTest(GetTestURL("sanity_check.html"), kNotIncognito); 52 SimpleTest(GetTestURL("sanity_check.html"), kNotIncognito);
52 } 53 }
53 54
54 IN_PROC_BROWSER_TEST_F(DomStorageBrowserTest, SanityCheckIncognito) { 55 IN_PROC_BROWSER_TEST_F(DomStorageBrowserTest, SanityCheckIncognito) {
55 SimpleTest(GetTestURL("sanity_check.html"), kIncognito); 56 SimpleTest(GetTestURL("sanity_check.html"), kIncognito);
56 } 57 }
OLDNEW
« no previous file with comments | « chrome/test/gpu/gpu_pixel_browsertest.cc ('k') | content/browser/fileapi/file_system_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698