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

Side by Side Diff: content/browser/fileapi/file_system_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, 5 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/bind.h" 5 #include "base/bind.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/test/thread_test_helper.h" 9 #include "base/test/thread_test_helper.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/browser_tabstrip.h" 11 #include "chrome/browser/ui/browser_tabstrip.h"
12 #include "chrome/test/base/in_process_browser_test.h" 12 #include "chrome/test/base/in_process_browser_test.h"
13 #include "chrome/test/base/testing_profile.h" 13 #include "chrome/test/base/testing_profile.h"
14 #include "chrome/test/base/ui_test_utils.h" 14 #include "chrome/test/base/ui_test_utils.h"
15 #include "content/browser/web_contents/web_contents_impl.h" 15 #include "content/browser/web_contents/web_contents_impl.h"
16 #include "content/public/common/content_switches.h" 16 #include "content/public/common/content_switches.h"
17 #include "content/public/test/browser_test_utils.h"
17 #include "webkit/quota/quota_manager.h" 18 #include "webkit/quota/quota_manager.h"
18 19
19 using content::BrowserThread; 20 using content::BrowserThread;
20 using quota::QuotaManager; 21 using quota::QuotaManager;
21 22
22 // This browser test is aimed towards exercising the FileAPI bindings and 23 // This browser test is aimed towards exercising the FileAPI bindings and
23 // the actual implementation that lives in the browser side. 24 // the actual implementation that lives in the browser side.
24 class FileSystemBrowserTest : public InProcessBrowserTest { 25 class FileSystemBrowserTest : public InProcessBrowserTest {
25 public: 26 public:
26 FileSystemBrowserTest() {} 27 FileSystemBrowserTest() {}
27 28
28 GURL testUrl(const FilePath& file_path) { 29 GURL testUrl(const FilePath& file_path) {
29 const FilePath kTestDir(FILE_PATH_LITERAL("fileapi")); 30 const FilePath kTestDir(FILE_PATH_LITERAL("fileapi"));
30 return ui_test_utils::GetTestUrl(kTestDir, file_path); 31 return ui_test_utils::GetTestUrl(kTestDir, file_path);
31 } 32 }
32 33
33 void SimpleTest(const GURL& test_url, bool incognito = false) { 34 void SimpleTest(const GURL& test_url, bool incognito = false) {
34 // The test page will perform tests on FileAPI, then navigate to either 35 // The test page will perform tests on FileAPI, then navigate to either
35 // a #pass or #fail ref. 36 // a #pass or #fail ref.
36 Browser* the_browser = incognito ? CreateIncognitoBrowser() : browser(); 37 Browser* the_browser = incognito ? CreateIncognitoBrowser() : browser();
37 38
38 LOG(INFO) << "Navigating to URL and blocking."; 39 LOG(INFO) << "Navigating to URL and blocking.";
39 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( 40 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
40 the_browser, test_url, 2); 41 the_browser, test_url, 2);
41 LOG(INFO) << "Navigation done."; 42 LOG(INFO) << "Navigation done.";
42 std::string result = 43 std::string result =
43 chrome::GetActiveWebContents(the_browser)->GetURL().ref(); 44 chrome::GetActiveWebContents(the_browser)->GetURL().ref();
44 if (result != "pass") { 45 if (result != "pass") {
45 std::string js_result; 46 std::string js_result;
46 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString( 47 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString(
47 chrome::GetActiveWebContents(the_browser)->GetRenderViewHost(), L"", 48 chrome::GetActiveWebContents(the_browser)->GetRenderViewHost(), L"",
48 L"window.domAutomationController.send(getLog())", &js_result)); 49 L"window.domAutomationController.send(getLog())", &js_result));
49 FAIL() << "Failed: " << js_result; 50 FAIL() << "Failed: " << js_result;
50 } 51 }
51 } 52 }
52 }; 53 };
53 54
54 class FileSystemBrowserTestWithLowQuota : public FileSystemBrowserTest { 55 class FileSystemBrowserTestWithLowQuota : public FileSystemBrowserTest {
55 public: 56 public:
56 virtual void SetUpOnMainThread() { 57 virtual void SetUpOnMainThread() {
(...skipping 27 matching lines...) Expand all
84 SimpleTest(testUrl(FilePath(FILE_PATH_LITERAL("request_test.html")))); 85 SimpleTest(testUrl(FilePath(FILE_PATH_LITERAL("request_test.html"))));
85 } 86 }
86 87
87 IN_PROC_BROWSER_TEST_F(FileSystemBrowserTest, CreateTest) { 88 IN_PROC_BROWSER_TEST_F(FileSystemBrowserTest, CreateTest) {
88 SimpleTest(testUrl(FilePath(FILE_PATH_LITERAL("create_test.html")))); 89 SimpleTest(testUrl(FilePath(FILE_PATH_LITERAL("create_test.html"))));
89 } 90 }
90 91
91 IN_PROC_BROWSER_TEST_F(FileSystemBrowserTestWithLowQuota, QuotaTest) { 92 IN_PROC_BROWSER_TEST_F(FileSystemBrowserTestWithLowQuota, QuotaTest) {
92 SimpleTest(testUrl(FilePath(FILE_PATH_LITERAL("quota_test.html")))); 93 SimpleTest(testUrl(FilePath(FILE_PATH_LITERAL("quota_test.html"))));
93 } 94 }
OLDNEW
« no previous file with comments | « content/browser/dom_storage/dom_storage_browsertest.cc ('k') | content/browser/in_process_webkit/indexed_db_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698