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

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

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

Powered by Google App Engine
This is Rietveld 408576698