Commit 4cdc9a28 authored by jam@chromium.org's avatar jam@chromium.org

Move over a bunch of tests from browser_tests to content_browsertests.

BUG=90448
Review URL: https://chromiumcodereview.appspot.com/10831023

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148507 0039d316-1c4b-4281-b951-d872f2087c98
parent c7b8db06
...@@ -857,7 +857,6 @@ ...@@ -857,7 +857,6 @@
'<(PRODUCT_DIR)/test_url_loader_data/', '<(PRODUCT_DIR)/test_url_loader_data/',
'test/data/automation/', 'test/data/automation/',
'test/data/captive_portal/', 'test/data/captive_portal/',
'test/data/device_orientation/',
'test/data/devtools/', 'test/data/devtools/',
'test/data/dom_automation/', 'test/data/dom_automation/',
'test/data/encoding_tests/auto_detect/', 'test/data/encoding_tests/auto_detect/',
...@@ -983,7 +982,6 @@ ...@@ -983,7 +982,6 @@
'test/data/extensions/uitest/plugins/', 'test/data/extensions/uitest/plugins/',
'test/data/extensions/uitest/window_open/', 'test/data/extensions/uitest/window_open/',
'test/data/fast_shutdown/', 'test/data/fast_shutdown/',
'test/data/fileapi/',
'test/data/google/', 'test/data/google/',
'test/data/http/', 'test/data/http/',
'test/data/login/', 'test/data/login/',
......
...@@ -3042,11 +3042,6 @@ ...@@ -3042,11 +3042,6 @@
'../content/browser/accessibility/dump_accessibility_tree_helper.h', '../content/browser/accessibility/dump_accessibility_tree_helper.h',
'../content/browser/accessibility/dump_accessibility_tree_helper_mac.mm', '../content/browser/accessibility/dump_accessibility_tree_helper_mac.mm',
'../content/browser/accessibility/dump_accessibility_tree_helper_win.cc', '../content/browser/accessibility/dump_accessibility_tree_helper_win.cc',
'../content/browser/child_process_security_policy_browsertest.cc',
'../content/browser/device_orientation/device_orientation_browsertest.cc',
'../content/browser/dom_storage/dom_storage_browsertest.cc',
'../content/browser/download/mhtml_generation_browsertest.cc',
'../content/browser/fileapi/file_system_browsertest.cc',
'../content/browser/in_process_webkit/indexed_db_browsertest.cc', '../content/browser/in_process_webkit/indexed_db_browsertest.cc',
'../content/browser/indexed_db/idbbindingutilities_browsertest.cc', '../content/browser/indexed_db/idbbindingutilities_browsertest.cc',
'../content/browser/plugin_data_remover_impl_browsertest.cc', '../content/browser/plugin_data_remover_impl_browsertest.cc',
......
<html>
<head>
<title>DeviceOrientation test</title>
<script type="text/javascript">
var eventCount = 0;
function checkOrientationEvent(event) {
// Return true iff the orientation is close enough to (1, 2, 3).
return Math.abs(event.alpha - 1) < 0.01 &&
Math.abs(event.beta - 2) < 0.01 &&
Math.abs(event.gamma - 3) < 0.01;
}
function onOrientation(event) {
if (checkOrientationEvent(event)) {
window.removeEventListener('deviceorientation', onOrientation);
pass();
} else {
fail();
}
}
function pass() {
document.getElementById('status').innerHTML = 'PASS';
document.location = '#pass';
}
function fail() {
document.location = '#fail';
}
</script>
</head>
<body onLoad="window.addEventListener('deviceorientation', onOrientation)">
<div id="status">FAIL</div>
</body>
</html>
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
function debug(message)
{
document.getElementById('status').innerHTML += '<br/>' + message;
}
function done(message)
{
if (document.location.hash == '#fail')
return;
if (message)
debug('PASS: ' + message);
else
debug('PASS');
document.location.hash = '#pass';
}
function fail(message)
{
debug('FAILED: ' + message);
document.location.hash = '#fail';
}
function getLog()
{
return '' + document.getElementById('status').innerHTML;
}
function fileErrorToString(e)
{
switch (e.code) {
case FileError.QUOTA_EXCEEDED_ERR:
return 'QUOTA_EXCEEDED_ERR';
case FileError.NOT_FOUND_ERR:
return 'NOT_FOUND_ERR';
case FileError.SECURITY_ERR:
return 'SECURITY_ERR';
case FileError.INVALID_MODIFICATION_ERR:
return 'INVALID_MODIFICATION_ERR';
case FileError.INVALID_STATE_ERR:
return 'INVALID_STATE_ERR';
default:
return 'Unknown Error';
}
}
function unexpectedErrorCallback(e)
{
fail('unexpectedErrorCallback:' + fileErrorToString(e));
}
<html>
<head>
<title>FileAPI create test</title>
<script type="text/javascript" src="common.js"></script>
<script type="text/javascript" src="create_test.js"></script>
</head>
<body onLoad="test()">
<div id="status">Starting...</div>
</body>
</html>
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
function requestFileSystemSuccess(fs)
{
fs.root.getFile('foo', {create: true, exclusive: false}, done,
function(e) { fail('Open:' + fileErrorToString(e)); } );
}
function test()
{
debug('Requesting FileSystem');
window.webkitRequestFileSystem(
window.TEMPORARY,
1024 * 1024,
requestFileSystemSuccess,
unexpectedErrorCallback);
}
<html>
<head>
<title>FileAPI quota test</title>
<script type="text/javascript" src="common.js"></script>
<script type="text/javascript" src="quota_test.js"></script>
</head>
<body onLoad="test()">
<div id="status">Starting...</div>
</body>
</html>
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
function truncateFailByQuota(fs) {
fs.root.getFile('fd', {create: false, exclusive: false}, function(fileEntry) {
fileEntry.createWriter(function(fileWriter) {
var failedInTruncate = false;
fileWriter.onerror = function(e) {
failedInTruncate = true;
};
fileWriter.onwriteend = function(e) {
if (failedInTruncate) {
fail(e.currentTarget.error);
} else {
done();
}
};
fileWriter.truncate(2500 * 1024);
}, unexpectedErrorCallback)
}, function(e) { fail('Open for 2nd truncate:' + fileErrorToString(e)); } );
}
function requestFileSystemSuccess(fs) {
fs.root.getFile('fd', {create: true, exclusive: false}, function(fileEntry) {
fileEntry.createWriter(function(fileWriter) {
var failedInTruncate = false;
fileWriter.onerror = function(e) {
debug(e.currentTarget.error);
failedInTruncate = true;
};
fileWriter.onwriteend = function() {
if (failedInTruncate) {
truncateFailByQuota(fs);
} else {
fail('Unexpectedly succeeded to truncate. It should fail by quota.');
}
};
fileWriter.truncate(10000 * 1024);
}, unexpectedErrorCallback)
}, function(e) { fail('Open for 1st truncate:' + fileErrorToString(e)); } );
}
function quotaSuccess(usage, quota) {
if (usage != 0)
fail('Usage is not zero: ' + usage);
if (quota != 5000 * 1024)
fail('Quota is not 5000KiB: ' + quota);
window.webkitRequestFileSystem(
window.TEMPORARY,
1024 * 1024,
requestFileSystemSuccess,
unexpectedErrorCallback);
}
function test() {
if (window.webkitStorageInfo) {
debug('Querying usage and quota.');
webkitStorageInfo.queryUsageAndQuota(webkitStorageInfo.TEMPORARY,
quotaSuccess,
unexpectedErrorCallback);
} else {
debug('This test requires window.webkitStorageInfo.');
}
}
<html>
<head>
<title>FileAPI request test</title>
<script type="text/javascript" src="common.js"></script>
<script type="text/javascript" src="request_test.js"></script>
</head>
<body onLoad="test()">
<div id="status">Starting...</div>
</body>
</html>
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
function requestFileSystemSuccess(fs)
{
debug('Requested successfully.');
done();
}
function test()
{
debug('Requesting FileSystem');
window.webkitRequestFileSystem(
window.TEMPORARY,
1024 * 1024,
requestFileSystemSuccess,
unexpectedErrorCallback);
}
...@@ -7,48 +7,42 @@ ...@@ -7,48 +7,42 @@
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/file_path.h" #include "base/file_path.h"
#include "base/process_util.h" #include "base/process_util.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/browser/child_process_security_policy_impl.h" #include "content/browser/child_process_security_policy_impl.h"
#include "content/browser/web_contents/web_contents_impl.h" #include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
#include "content/public/common/result_codes.h" #include "content/public/common/result_codes.h"
#include "content/shell/shell.h"
#include "content/test/content_browser_test.h"
#include "content/test/content_browser_test_utils.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
using content::WebContents;
class ChildProcessSecurityPolicyInProcessBrowserTest class ChildProcessSecurityPolicyInProcessBrowserTest
: public InProcessBrowserTest { : public content::ContentBrowserTest {
public: public:
virtual void SetUp() { virtual void SetUp() {
EXPECT_EQ( EXPECT_EQ(
ChildProcessSecurityPolicyImpl::GetInstance()->security_state_.size(), ChildProcessSecurityPolicyImpl::GetInstance()->security_state_.size(),
0U); 0U);
InProcessBrowserTest::SetUp(); ContentBrowserTest::SetUp();
} }
virtual void TearDown() { virtual void TearDown() {
EXPECT_EQ( EXPECT_EQ(
ChildProcessSecurityPolicyImpl::GetInstance()->security_state_.size(), ChildProcessSecurityPolicyImpl::GetInstance()->security_state_.size(),
0U); 0U);
InProcessBrowserTest::TearDown(); ContentBrowserTest::TearDown();
} }
}; };
IN_PROC_BROWSER_TEST_F(ChildProcessSecurityPolicyInProcessBrowserTest, NoLeak) { IN_PROC_BROWSER_TEST_F(ChildProcessSecurityPolicyInProcessBrowserTest, NoLeak) {
const FilePath kTestDir(FILE_PATH_LITERAL("google")); GURL url = content::GetTestUrl("", "simple_page.html");
const FilePath kTestFile(FILE_PATH_LITERAL("google.html"));
GURL url(ui_test_utils::GetTestUrl(kTestDir, kTestFile));
ui_test_utils::NavigateToURL(browser(), url); content::NavigateToURL(shell(), url);
EXPECT_EQ( EXPECT_EQ(
ChildProcessSecurityPolicyImpl::GetInstance()->security_state_.size(), ChildProcessSecurityPolicyImpl::GetInstance()->security_state_.size(),
1U); 1U);
WebContents* web_contents = chrome::GetWebContentsAt(browser(), 0); content::WebContents* web_contents = shell()->web_contents();
ASSERT_TRUE(web_contents != NULL);
base::KillProcess(web_contents->GetRenderProcessHost()->GetHandle(), base::KillProcess(web_contents->GetRenderProcessHost()->GetHandle(),
content::RESULT_CODE_KILLED, true); content::RESULT_CODE_KILLED, true);
......
...@@ -5,14 +5,13 @@ ...@@ -5,14 +5,13 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/file_path.h" #include "base/file_path.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/browser/device_orientation/orientation.h" #include "content/browser/device_orientation/orientation.h"
#include "content/browser/device_orientation/provider.h" #include "content/browser/device_orientation/provider.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#include "content/shell/shell.h"
#include "content/test/content_browser_test.h"
#include "content/test/content_browser_test_utils.h"
namespace device_orientation { namespace device_orientation {
...@@ -39,17 +38,12 @@ class MockProvider : public Provider { ...@@ -39,17 +38,12 @@ class MockProvider : public Provider {
virtual ~MockProvider() {} virtual ~MockProvider() {}
}; };
class DeviceOrientationBrowserTest : public InProcessBrowserTest { class DeviceOrientationBrowserTest : public content::ContentBrowserTest {
public: public:
// From InProcessBrowserTest. // From ContentBrowserTest.
virtual void SetUpCommandLine(CommandLine* command_line) { virtual void SetUpCommandLine(CommandLine* command_line) {
EXPECT_TRUE(!command_line->HasSwitch(switches::kDisableDeviceOrientation)); EXPECT_TRUE(!command_line->HasSwitch(switches::kDisableDeviceOrientation));
} }
GURL testUrl(const FilePath::CharType* filename) {
const FilePath kTestDir(FILE_PATH_LITERAL("device_orientation"));
return ui_test_utils::GetTestUrl(kTestDir, FilePath(filename));
}
}; };
// crbug.com/113952 // crbug.com/113952
...@@ -65,14 +59,13 @@ IN_PROC_BROWSER_TEST_F(DeviceOrientationBrowserTest, BasicTest) { ...@@ -65,14 +59,13 @@ IN_PROC_BROWSER_TEST_F(DeviceOrientationBrowserTest, BasicTest) {
// The test page will register an event handler for orientation events, // The test page will register an event handler for orientation events,
// expects to get an event with kTestOrientation orientation, // expects to get an event with kTestOrientation orientation,
// then removes the event handler and navigates to #pass. // then removes the event handler and navigates to #pass.
GURL test_url = testUrl(FILE_PATH_LITERAL("device_orientation_test.html")); GURL test_url = content::GetTestUrl(
ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(browser(), "device_orientation", "device_orientation_test.html");
test_url, content::NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 2);
2);
// Check that the page got the event it expected and that the provider // Check that the page got the event it expected and that the provider
// saw requests for adding and removing an observer. // saw requests for adding and removing an observer.
EXPECT_EQ("pass", chrome::GetActiveWebContents(browser())->GetURL().ref()); EXPECT_EQ("pass", shell()->web_contents()->GetURL().ref());
EXPECT_TRUE(provider->added_observer_); EXPECT_TRUE(provider->added_observer_);
EXPECT_TRUE(provider->removed_observer_); EXPECT_TRUE(provider->removed_observer_);
} }
......
...@@ -3,42 +3,33 @@ ...@@ -3,42 +3,33 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "base/path_service.h" #include "base/path_service.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/browser/web_contents/web_contents_impl.h" #include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/common/content_paths.h" #include "content/public/common/content_paths.h"
#include "content/public/test/browser_test_utils.h" #include "content/public/test/browser_test_utils.h"
#include "content/shell/shell.h"
#include "content/test/content_browser_test.h"
#include "content/test/content_browser_test_utils.h"
#include "net/base/net_util.h" #include "net/base/net_util.h"
#include "webkit/dom_storage/dom_storage_types.h" #include "webkit/dom_storage/dom_storage_types.h"
namespace content {
// This browser test is aimed towards exercising the DomStorage system // This browser test is aimed towards exercising the DomStorage system
// from end-to-end. // from end-to-end.
class DomStorageBrowserTest : public InProcessBrowserTest { class DomStorageBrowserTest : public ContentBrowserTest {
public: public:
DomStorageBrowserTest() {} DomStorageBrowserTest() {}
GURL GetTestURL(const char* name) {
FilePath file_name = FilePath().AppendASCII(name);
FilePath dir;
PathService::Get(content::DIR_TEST_DATA, &dir);
return net::FilePathToFileURL(
dir.Append(FILE_PATH_LITERAL("dom_storage")).Append(file_name));
}
void SimpleTest(const GURL& test_url, bool incognito) { void SimpleTest(const GURL& test_url, bool incognito) {
// The test page will perform tests then navigate to either // The test page will perform tests then navigate to either
// a #pass or #fail ref. // a #pass or #fail ref.
Browser* the_browser = incognito ? CreateIncognitoBrowser() : browser(); Shell* the_browser = incognito ? CreateOffTheRecordBrowser() : shell();
ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( NavigateToURLBlockUntilNavigationsComplete(the_browser, test_url, 2);
the_browser, test_url, 2); std::string result = the_browser->web_contents()->GetURL().ref();
std::string result =
chrome::GetActiveWebContents(the_browser)->GetURL().ref();
if (result != "pass") { if (result != "pass") {
std::string js_result; std::string js_result;
ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString( ASSERT_TRUE(ExecuteJavaScriptAndExtractString(
chrome::GetActiveWebContents(the_browser)->GetRenderViewHost(), L"", the_browser->web_contents()->GetRenderViewHost(), L"",
L"window.domAutomationController.send(getLog())", &js_result)); L"window.domAutomationController.send(getLog())", &js_result));
FAIL() << "Failed: " << js_result; FAIL() << "Failed: " << js_result;
} }
...@@ -49,9 +40,11 @@ static const bool kIncognito = true; ...@@ -49,9 +40,11 @@ static const bool kIncognito = true;
static const bool kNotIncognito = false; static const bool kNotIncognito = false;
IN_PROC_BROWSER_TEST_F(DomStorageBrowserTest, SanityCheck) { IN_PROC_BROWSER_TEST_F(DomStorageBrowserTest, SanityCheck) {
SimpleTest(GetTestURL("sanity_check.html"), kNotIncognito); SimpleTest(GetTestUrl("dom_storage", "sanity_check.html"), kNotIncognito);
} }
IN_PROC_BROWSER_TEST_F(DomStorageBrowserTest, SanityCheckIncognito) { IN_PROC_BROWSER_TEST_F(DomStorageBrowserTest, SanityCheckIncognito) {
SimpleTest(GetTestURL("sanity_check.html"), kIncognito); SimpleTest(GetTestUrl("dom_storage", "sanity_check.html"), kIncognito);
} }
} // namespace content
...@@ -4,21 +4,19 @@ ...@@ -4,21 +4,19 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/file_path.h" #include "base/file_path.h"
#include "base/run_loop.h"
#include "base/scoped_temp_dir.h" #include "base/scoped_temp_dir.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/test/test_utils.h"
#include "content/shell/shell.h"
#include "content/test/content_browser_test.h"
#include "content/test/content_browser_test_utils.h"
#include "net/test/test_server.h" #include "net/test/test_server.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
using content::WebContents; namespace content {
namespace { class MHTMLGenerationTest : public ContentBrowserTest {
class MHTMLGenerationTest : public InProcessBrowserTest {
public: public:
MHTMLGenerationTest() : mhtml_generated_(false), file_size_(0) {} MHTMLGenerationTest() : mhtml_generated_(false), file_size_(0) {}
...@@ -31,7 +29,7 @@ class MHTMLGenerationTest : public InProcessBrowserTest { ...@@ -31,7 +29,7 @@ class MHTMLGenerationTest : public InProcessBrowserTest {
protected: protected:
virtual void SetUp() { virtual void SetUp() {
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
InProcessBrowserTest::SetUp(); ContentBrowserTest::SetUp();
} }
bool mhtml_generated() const { return mhtml_generated_; } bool mhtml_generated() const { return mhtml_generated_; }
...@@ -54,16 +52,14 @@ IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTML) { ...@@ -54,16 +52,14 @@ IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTML) {
FilePath path(temp_dir_.path()); FilePath path(temp_dir_.path());
path = path.Append(FILE_PATH_LITERAL("test.mht")); path = path.Append(FILE_PATH_LITERAL("test.mht"));
ui_test_utils::NavigateToURL(browser(), NavigateToURL(shell(), test_server()->GetURL("files/simple_page.html"));
test_server()->GetURL("files/google/google.html"));
WebContents* web_contents = chrome::GetActiveWebContents(browser()); shell()->web_contents()->GenerateMHTML(
web_contents->GenerateMHTML(path, path, base::Bind(&MHTMLGenerationTest::MHTMLGenerated, this));
base::Bind(&MHTMLGenerationTest::MHTMLGenerated,
this));
// Block until the MHTML is generated. // Block until the MHTML is generated.
ui_test_utils::RunMessageLoop(); base::RunLoop run_loop;
RunThisRunLoop(&run_loop);
EXPECT_TRUE(mhtml_generated()); EXPECT_TRUE(mhtml_generated());
EXPECT_GT(file_size(), 0); EXPECT_GT(file_size(), 0);
...@@ -74,4 +70,4 @@ IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTML) { ...@@ -74,4 +70,4 @@ IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTML) {
EXPECT_GT(file_size, 100); EXPECT_GT(file_size, 100);
} }
} // namespace } // namespace content
...@@ -7,45 +7,40 @@ ...@@ -7,45 +7,40 @@
#include "base/file_path.h" #include "base/file_path.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/test/thread_test_helper.h" #include "base/test/thread_test_helper.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/browser/web_contents/web_contents_impl.h" #include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#include "content/public/test/browser_test_utils.h" #include "content/public/test/browser_test_utils.h"
#include "content/shell/shell.h"
#include "content/test/content_browser_test.h"
#include "content/test/content_browser_test_utils.h"
#include "net/test/test_server.h"
#include "webkit/quota/quota_manager.h" #include "webkit/quota/quota_manager.h"
using content::BrowserThread;
using quota::QuotaManager; using quota::QuotaManager;
namespace content {
// This browser test is aimed towards exercising the FileAPI bindings and // This browser test is aimed towards exercising the FileAPI bindings and
// the actual implementation that lives in the browser side. // the actual implementation that lives in the browser side.
class FileSystemBrowserTest : public InProcessBrowserTest { class FileSystemBrowserTest : public ContentBrowserTest {
public: public:
FileSystemBrowserTest() {} FileSystemBrowserTest() {}
GURL testUrl(const FilePath& file_path) {
const FilePath kTestDir(FILE_PATH_LITERAL("fileapi"));
return ui_test_utils::GetTestUrl(kTestDir, file_path);
}
void SimpleTest(const GURL& test_url, bool incognito = false) { void SimpleTest(const GURL& test_url, bool incognito = false) {
// The test page will perform tests on FileAPI, then navigate to either // The test page will perform tests on FileAPI, then navigate to either
// a #pass or #fail ref. // a #pass or #fail ref.
Browser* the_browser = incognito ? CreateIncognitoBrowser() : browser(); Shell* the_browser = incognito ? CreateOffTheRecordBrowser() : shell();
LOG(INFO) << "Navigating to URL and blocking."; LOG(INFO) << "Navigating to URL and blocking.";
ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( NavigateToURLBlockUntilNavigationsComplete(the_browser, test_url, 2);
the_browser, test_url, 2);
LOG(INFO) << "Navigation done."; LOG(INFO) << "Navigation done.";
std::string result = std::string result = the_browser->web_contents()->GetURL().ref();
chrome::GetActiveWebContents(the_browser)->GetURL().ref();
if (result != "pass") { if (result != "pass") {
std::string js_result; std::string js_result;
ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString( ASSERT_TRUE(ExecuteJavaScriptAndExtractString(
chrome::GetActiveWebContents(the_browser)->GetRenderViewHost(), L"", the_browser->web_contents()->GetRenderViewHost(), L"",
L"window.domAutomationController.send(getLog())", &js_result)); L"window.domAutomationController.send(getLog())", &js_result));
FAIL() << "Failed: " << js_result; FAIL() << "Failed: " << js_result;
} }
...@@ -60,7 +55,8 @@ class FileSystemBrowserTestWithLowQuota : public FileSystemBrowserTest { ...@@ -60,7 +55,8 @@ class FileSystemBrowserTestWithLowQuota : public FileSystemBrowserTest {
kInitialQuotaKilobytes * 1024 * QuotaManager::kPerHostTemporaryPortion; kInitialQuotaKilobytes * 1024 * QuotaManager::kPerHostTemporaryPortion;
SetTempQuota( SetTempQuota(
kTemporaryStorageQuotaMaxSize, kTemporaryStorageQuotaMaxSize,
content::BrowserContext::GetQuotaManager(browser()->profile())); BrowserContext::GetQuotaManager(
shell()->web_contents()->GetBrowserContext()));
} }
static void SetTempQuota(int64 bytes, scoped_refptr<QuotaManager> qm) { static void SetTempQuota(int64 bytes, scoped_refptr<QuotaManager> qm) {
...@@ -82,13 +78,15 @@ class FileSystemBrowserTestWithLowQuota : public FileSystemBrowserTest { ...@@ -82,13 +78,15 @@ class FileSystemBrowserTestWithLowQuota : public FileSystemBrowserTest {
}; };
IN_PROC_BROWSER_TEST_F(FileSystemBrowserTest, RequestTest) { IN_PROC_BROWSER_TEST_F(FileSystemBrowserTest, RequestTest) {
SimpleTest(testUrl(FilePath(FILE_PATH_LITERAL("request_test.html")))); SimpleTest(GetTestUrl("fileapi", "request_test.html"));
} }
IN_PROC_BROWSER_TEST_F(FileSystemBrowserTest, CreateTest) { IN_PROC_BROWSER_TEST_F(FileSystemBrowserTest, CreateTest) {
SimpleTest(testUrl(FilePath(FILE_PATH_LITERAL("create_test.html")))); SimpleTest(GetTestUrl("fileapi", "create_test.html"));
} }
IN_PROC_BROWSER_TEST_F(FileSystemBrowserTestWithLowQuota, QuotaTest) { IN_PROC_BROWSER_TEST_F(FileSystemBrowserTestWithLowQuota, QuotaTest) {
SimpleTest(testUrl(FilePath(FILE_PATH_LITERAL("quota_test.html")))); SimpleTest(GetTestUrl("fileapi", "quota_test.html"));
} }
} // namespace content
...@@ -101,7 +101,7 @@ class PluginTest : public ContentBrowserTest { ...@@ -101,7 +101,7 @@ class PluginTest : public ContentBrowserTest {
} }
void NavigateAway() { void NavigateAway() {
GURL url = GetTestUrl(".", "simple_page.html"); GURL url = GetTestUrl("", "simple_page.html");
LoadAndWait(url); LoadAndWait(url);
} }
......
...@@ -552,6 +552,11 @@ ...@@ -552,6 +552,11 @@
'sources': [ 'sources': [
'browser/appcache/appcache_browsertest.cc', 'browser/appcache/appcache_browsertest.cc',
'browser/audio_browsertest.cc', 'browser/audio_browsertest.cc',
'browser/child_process_security_policy_browsertest.cc',
'browser/device_orientation/device_orientation_browsertest.cc',
'browser/dom_storage/dom_storage_browsertest.cc',
'browser/download/mhtml_generation_browsertest.cc',
'browser/fileapi/file_system_browsertest.cc',
'browser/in_process_webkit/indexed_db_layout_browsertest.cc', 'browser/in_process_webkit/indexed_db_layout_browsertest.cc',
'browser/media_browsertest.cc', 'browser/media_browsertest.cc',
'browser/plugin_browsertest.cc', 'browser/plugin_browsertest.cc',
......
...@@ -115,10 +115,7 @@ void ContentBrowserTest::RunTestOnMainThreadLoop() { ...@@ -115,10 +115,7 @@ void ContentBrowserTest::RunTestOnMainThreadLoop() {
pool.Recycle(); pool.Recycle();
#endif #endif
for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator()); Shell::CloseAllWindows();
!i.IsAtEnd(); i.Advance()) {
i.GetCurrentValue()->FastShutdownIfPossible();
}
} }
Shell* ContentBrowserTest::CreateBrowser() { Shell* ContentBrowserTest::CreateBrowser() {
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "content/public/browser/notification_source.h" #include "content/public/browser/notification_source.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/common/content_paths.h" #include "content/public/common/content_paths.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_navigation_observer.h" #include "content/public/test/test_navigation_observer.h"
#include "content/public/test/test_utils.h" #include "content/public/test/test_utils.h"
#include "content/shell/shell.h" #include "content/shell/shell.h"
...@@ -31,12 +32,15 @@ GURL GetTestUrl(const char* dir, const char* file) { ...@@ -31,12 +32,15 @@ GURL GetTestUrl(const char* dir, const char* file) {
return net::FilePathToFileURL(GetTestFilePath(dir, file)); return net::FilePathToFileURL(GetTestFilePath(dir, file));
} }
void NavigateToURL(Shell* window, const GURL& url) { void NavigateToURLBlockUntilNavigationsComplete(Shell* window,
const GURL& url,
int number_of_navigations) {
WaitForLoadStop(window->web_contents());
NavigationController* controller = &window->web_contents()->GetController(); NavigationController* controller = &window->web_contents()->GetController();
TestNavigationObserver same_tab_observer( TestNavigationObserver same_tab_observer(
Source<NavigationController>(controller), Source<NavigationController>(controller),
NULL, NULL,
1); number_of_navigations);
window->LoadURL(url); window->LoadURL(url);
...@@ -46,6 +50,10 @@ void NavigateToURL(Shell* window, const GURL& url) { ...@@ -46,6 +50,10 @@ void NavigateToURL(Shell* window, const GURL& url) {
GetQuitTaskForRunLoop(&run_loop)); GetQuitTaskForRunLoop(&run_loop));
} }
void NavigateToURL(Shell* window, const GURL& url) {
NavigateToURLBlockUntilNavigationsComplete(window, url, 1);
}
void WaitForAppModalDialog(Shell* window) { void WaitForAppModalDialog(Shell* window) {
ShellJavaScriptDialogCreator* dialog_creator = ShellJavaScriptDialogCreator* dialog_creator =
static_cast<ShellJavaScriptDialogCreator*>( static_cast<ShellJavaScriptDialogCreator*>(
......
...@@ -38,6 +38,12 @@ GURL GetTestUrl(const char* dir, const char* file); ...@@ -38,6 +38,12 @@ GURL GetTestUrl(const char* dir, const char* file);
// navigation finishes. // navigation finishes.
void NavigateToURL(Shell* window, const GURL& url); void NavigateToURL(Shell* window, const GURL& url);
// Navigates the selected tab of |window| to |url|, blocking until the given
// number of navigations finishes.
void NavigateToURLBlockUntilNavigationsComplete(Shell* window,
const GURL& url,
int number_of_navigations);
// Wait until an application modal dialog is requested. // Wait until an application modal dialog is requested.
void WaitForAppModalDialog(Shell* window); void WaitForAppModalDialog(Shell* window);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment