summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/chrome_content_browser_client.cc23
-rw-r--r--chrome/chrome_tests.gypi58
-rw-r--r--chrome/test/ui/ppapi_uitest.cc287
-rw-r--r--ppapi/tests/test_view.cc9
-rw-r--r--ppapi/tests/testing_instance.cc9
-rw-r--r--ppapi/tests/testing_instance.h31
6 files changed, 246 insertions, 171 deletions
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index 7fc33a1..f9bc449 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -288,16 +288,6 @@ namespace chrome {
ChromeContentBrowserClient::ChromeContentBrowserClient() {
for (size_t i = 0; i < arraysize(kPredefinedAllowedSocketOrigins); ++i)
allowed_socket_origins_.insert(kPredefinedAllowedSocketOrigins[i]);
-
- const CommandLine& command_line = *CommandLine::ForCurrentProcess();
- std::string allowed_list =
- command_line.GetSwitchValueASCII(switches::kAllowNaClSocketAPI);
- if (!allowed_list.empty()) {
- StringTokenizer t(allowed_list, ",");
- while (t.GetNext()) {
- allowed_socket_origins_.insert(t.token());
- }
- }
}
ChromeContentBrowserClient::~ChromeContentBrowserClient() {
@@ -1532,6 +1522,19 @@ bool ChromeContentBrowserClient::AllowSocketAPI(
if (allowed_socket_origins_.count(host))
return true;
+ // Need to check this now and not on construction because otherwise it won't
+ // work with browser_tests.
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+ std::string allowed_list =
+ command_line.GetSwitchValueASCII(switches::kAllowNaClSocketAPI);
+ if (!allowed_list.empty()) {
+ StringTokenizer t(allowed_list, ",");
+ while (t.GetNext()) {
+ if (t.token() == host)
+ return true;
+ }
+ }
+
Profile* profile = Profile::FromBrowserContext(browser_context);
if (!profile || !profile->GetExtensionService())
return false;
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 5c50e76..64c9244 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -773,24 +773,6 @@
{
'target_name': 'ui_tests',
'type': 'executable',
- 'copies': [
- {
- 'destination': '<(PRODUCT_DIR)',
- 'files': [
- # Keep 'test_case.html.mock-http-headers' with 'test_case.html'.
- '../ppapi/tests/test_case.html',
- '../ppapi/tests/test_case.html.mock-http-headers',
- '../ppapi/tests/test_page.css',
- '../ppapi/native_client/tests/ppapi_tests/test_case.nmf',
- ],
- },
- {
- 'destination': '<(PRODUCT_DIR)/test_url_loader_data',
- 'files': [
- '../ppapi/tests/test_url_loader_data/hello.txt',
- ],
- },
- ],
'dependencies': [
'browser',
'chrome',
@@ -809,7 +791,6 @@
'../third_party/icu/icu.gyp:icuuc',
'../third_party/libxml/libxml.gyp:libxml',
# run time dependencies
- '../ppapi/ppapi_internal.gyp:ppapi_tests',
'../third_party/mesa/mesa.gyp:osmesa',
'../webkit/webkit.gyp:pull_in_copy_TestNetscapePlugIn',
],
@@ -817,6 +798,9 @@
'..',
],
'sources': [
+ # NOTE: DON'T ADD NEW TESTS HERE!
+ # New tests should be browser_tests. browser_tests are sharded and are
+ # less flakier.
'app/chrome_main_uitest.cc',
'browser/audio_layout_uitest.cc',
'browser/browser_encoding_uitest.cc',
@@ -864,20 +848,15 @@
'test/ui/layout_plugin_uitest.cc',
'test/ui/named_interface_uitest.cc',
'test/ui/npapi_uitest.cc',
- 'test/ui/ppapi_uitest.cc',
'test/ui/sandbox_uitests.cc',
'../content/browser/appcache/appcache_ui_test.cc',
'../content/browser/in_process_webkit/dom_storage_uitest.cc',
'../content/browser/in_process_webkit/indexed_db_uitest.cc',
'../content/browser/renderer_host/resource_dispatcher_host_uitest.cc',
'../content/worker/test/worker_uitest.cc',
+ # DON'T ADD NEW FILES! SEE NOTE AT TOP OF SECTION.
],
'conditions': [
- ['disable_nacl==0 and disable_nacl_untrusted==0', {
- 'dependencies': [
- '../ppapi/ppapi_untrusted.gyp:ppapi_nacl_tests',
- ],
- }],
['target_arch!="arm"', {
'dependencies': [
'../webkit/webkit.gyp:copy_npapi_test_plugin',
@@ -2521,6 +2500,24 @@
'type': 'executable',
'msvs_cygwin_shell': 0,
'msvs_cygwin_dirs': ['<(DEPTH)/third_party/cygwin'],
+ 'copies': [
+ {
+ 'destination': '<(PRODUCT_DIR)',
+ 'files': [
+ # Keep 'test_case.html.mock-http-headers' with 'test_case.html'.
+ '../ppapi/tests/test_case.html',
+ '../ppapi/tests/test_case.html.mock-http-headers',
+ '../ppapi/tests/test_page.css',
+ '../ppapi/native_client/tests/ppapi_tests/test_case.nmf',
+ ],
+ },
+ {
+ 'destination': '<(PRODUCT_DIR)/test_url_loader_data',
+ 'files': [
+ '../ppapi/tests/test_url_loader_data/hello.txt',
+ ],
+ },
+ ],
'dependencies': [
'browser',
'../sync/protocol/sync_proto.gyp:sync_proto',
@@ -2545,6 +2542,7 @@
'../v8/tools/gyp/v8.gyp:v8',
'../webkit/webkit.gyp:test_shell_test_support',
# Runtime dependencies
+ '../ppapi/ppapi_internal.gyp:ppapi_tests',
'../third_party/mesa/mesa.gyp:osmesa',
'../webkit/webkit.gyp:pull_in_copy_TestNetscapePlugIn',
],
@@ -2891,6 +2889,7 @@
'test/data/webui/print_preview.cc',
'test/data/webui/print_preview.js',
'test/gpu/gpu_feature_browsertest.cc',
+ 'test/ui/ppapi_uitest.cc',
# TODO(craig): Rename this and run from base_unittests when the test
# is safe to run there. See http://crbug.com/78722 for details.
'../base/files/file_path_watcher_browsertest.cc',
@@ -2951,10 +2950,17 @@
},
],
'conditions': [
- ['disable_nacl!=1', {
+ ['disable_nacl==0', {
'sources':[
'browser/extensions/extension_nacl_browsertest.cc',
],
+ 'conditions': [
+ ['disable_nacl_untrusted==0', {
+ 'dependencies': [
+ '../ppapi/ppapi_untrusted.gyp:ppapi_nacl_tests',
+ ],
+ }],
+ ],
}],
['chromeos==0', {
'sources/': [
diff --git a/chrome/test/ui/ppapi_uitest.cc b/chrome/test/ui/ppapi_uitest.cc
index ce74a51..f981e65 100644
--- a/chrome/test/ui/ppapi_uitest.cc
+++ b/chrome/test/ui/ppapi_uitest.cc
@@ -2,23 +2,33 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/command_line.h"
#include "base/file_util.h"
#include "base/path_service.h"
+#include "base/stringprintf.h"
+#include "base/string_util.h"
#include "base/test/test_timeouts.h"
+#include "base/timer.h"
#include "build/build_config.h"
-#include "content/public/common/content_switches.h"
-#include "content/common/pepper_plugin_registry.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
-#include "chrome/test/automation/browser_proxy.h"
-#include "chrome/test/automation/tab_proxy.h"
+#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
-#include "chrome/test/ui/ui_test.h"
+#include "content/common/pepper_plugin_registry.h"
+#include "content/public/browser/dom_operation_notification_details.h"
+#include "content/public/browser/notification_types.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/common/content_switches.h"
#include "content/public/common/url_constants.h"
#include "net/base/net_util.h"
#include "net/test/test_server.h"
#include "webkit/plugins/plugin_switches.h"
+using content::DomOperationNotificationDetails;
+using content::RenderViewHost;
+
namespace {
// Platform-specific filename relative to the chrome executable.
@@ -30,20 +40,93 @@ const char library_name[] = "ppapi_tests.plugin";
const char library_name[] = "libppapi_tests.so";
#endif
+// The large timeout was causing the cycle time for the whole test suite
+// to be too long when a tiny bug caused all tests to timeout.
+// http://crbug.com/108264
+static int kTimeoutMs = 90000;
+//static int kTimeoutMs = TestTimeouts::large_test_timeout_ms());
+
+class TestFinishObserver : public content::NotificationObserver {
+ public:
+ explicit TestFinishObserver(RenderViewHost* render_view_host, int timeout_s)
+ : finished_(false), waiting_(false), timeout_s_(timeout_s) {
+ registrar_.Add(this, content::NOTIFICATION_DOM_OPERATION_RESPONSE,
+ content::Source<RenderViewHost>(render_view_host));
+ timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(timeout_s),
+ this, &TestFinishObserver::OnTimeout);
+ }
+
+ bool WaitForFinish() {
+ if (!finished_) {
+ waiting_ = true;
+ ui_test_utils::RunMessageLoop();
+ waiting_ = false;
+ }
+ return finished_;
+ }
+
+ virtual void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
+ DCHECK(type == content::NOTIFICATION_DOM_OPERATION_RESPONSE);
+ content::Details<DomOperationNotificationDetails> dom_op_details(details);
+ // We might receive responses for other script execution, but we only
+ // care about the test finished message.
+ std::string response;
+ TrimString(dom_op_details->json, "\"", &response);
+ if (response == "...") {
+ timer_.Stop();
+ timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(timeout_s_),
+ this, &TestFinishObserver::OnTimeout);
+ } else {
+ result_ = response;
+ finished_ = true;
+ if (waiting_)
+ MessageLoopForUI::current()->Quit();
+ }
+ }
+
+ std::string result() const { return result_; }
+
+ void Reset() {
+ finished_ = false;
+ waiting_ = false;
+ result_.clear();
+ }
+
+ private:
+ void OnTimeout() {
+ MessageLoopForUI::current()->Quit();
+ }
+
+ bool finished_;
+ bool waiting_;
+ int timeout_s_;
+ std::string result_;
+ content::NotificationRegistrar registrar_;
+ base::RepeatingTimer<TestFinishObserver> timer_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestFinishObserver);
+};
+
} // namespace
-class PPAPITestBase : public UITest {
+class PPAPITestBase : public InProcessBrowserTest {
public:
PPAPITestBase() {
+ EnableDOMAutomation();
+ }
+
+ virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
// The test sends us the result via a cookie.
- launch_arguments_.AppendSwitch(switches::kEnableFileCookies);
+ command_line->AppendSwitch(switches::kEnableFileCookies);
// Some stuff is hung off of the testing interface which is not enabled
// by default.
- launch_arguments_.AppendSwitch(switches::kEnablePepperTesting);
+ command_line->AppendSwitch(switches::kEnablePepperTesting);
// Smooth scrolling confuses the scrollbar test.
- launch_arguments_.AppendSwitch(switches::kDisableSmoothScrolling);
+ command_line->AppendSwitch(switches::kDisableSmoothScrolling);
}
virtual std::string BuildQuery(const std::string& base,
@@ -69,13 +152,8 @@ class PPAPITestBase : public UITest {
}
void RunTest(const std::string& test_case) {
- scoped_refptr<TabProxy> tab = GetActiveTab();
- EXPECT_TRUE(tab.get());
- if (!tab.get())
- return;
GURL url = GetTestFileUrl(test_case);
- EXPECT_TRUE(tab->NavigateToURLBlockUntilNavigationsComplete(url, 1));
- RunTestURL(tab, url);
+ RunTestURL(url);
}
void RunTestViaHTTP(const std::string& test_case) {
@@ -119,10 +197,8 @@ class PPAPITestBase : public UITest {
ASSERT_TRUE(test_server.Start());
std::string query = BuildQuery("files/test_case.html?", test_case);
- scoped_refptr<TabProxy> tab = GetActiveTab();
GURL url = test_server.GetURL(query);
- EXPECT_TRUE(tab->NavigateToURLBlockUntilNavigationsComplete(url, 1));
- RunTestURL(tab, url);
+ RunTestURL(url);
}
void RunTestWithWebSocketServer(const std::string& test_case) {
@@ -146,42 +222,20 @@ class PPAPITestBase : public UITest {
protected:
// Runs the test for a tab given the tab that's already navigated to the
// given URL.
- void RunTestURL(scoped_refptr<TabProxy> tab, const GURL& test_url) {
- ASSERT_TRUE(tab.get());
-
- // The large timeout was causing the cycle time for the whole test suite
- // to be too long when a tiny bug caused all tests to timeout.
- // http://crbug.com/108264
- int timeout_ms = 90000;
- //int timeout_ms = TestTimeouts::large_test_timeout_ms());
-
+ void RunTestURL(const GURL& test_url) {
// See comment above TestingInstance in ppapi/test/testing_instance.h.
- // Basically it sets a series of numbered cookies. The value of "..." means
- // it's still working and we should continue to wait, any other value
- // indicates completion (in this case it will start with "PASS" or "FAIL").
- // This keeps us from timing out on cookie waits for long tests.
- int progress_number = 0;
- std::string progress;
- while (true) {
- std::string cookie_name = StringPrintf("PPAPI_PROGRESS_%d",
- progress_number);
- progress = WaitUntilCookieNonEmpty(tab.get(), test_url,
- cookie_name.c_str(), timeout_ms);
- if (progress != "...")
- break;
- progress_number++;
- }
+ // Basically it sends messages using the DOM automation controller. The
+ // value of "..." means it's still working and we should continue to wait,
+ // any other value indicates completion (in this case it will start with
+ // "PASS" or "FAIL"). This keeps us from timing out on waits for long tests.
+ TestFinishObserver observer(
+ browser()->GetSelectedWebContents()->GetRenderViewHost(), kTimeoutMs);
- if (progress_number == 0) {
- // Failing the first time probably means the plugin wasn't loaded.
- ASSERT_FALSE(progress.empty())
- << "Plugin couldn't be loaded. Make sure the PPAPI test plugin is "
- << "built, in the right place, and doesn't have any missing symbols.";
- } else {
- ASSERT_FALSE(progress.empty()) << "Test timed out.";
- }
+ ui_test_utils::NavigateToURL(browser(), test_url);
+
+ ASSERT_TRUE(observer.WaitForFinish()) << "Test timed out.";
- EXPECT_STREQ("PASS", progress.c_str());
+ EXPECT_STREQ("PASS", observer.result().c_str());
}
};
@@ -190,20 +244,24 @@ class PPAPITestBase : public UITest {
class PPAPITest : public PPAPITestBase {
public:
PPAPITest() {
+ }
+
+ virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
+ PPAPITestBase::SetUpCommandLine(command_line);
+
// Append the switch to register the pepper plugin.
// library name = <out dir>/<test_name>.<library_extension>
// MIME type = application/x-ppapi-<test_name>
FilePath plugin_dir;
- EXPECT_TRUE(PathService::Get(base::DIR_EXE, &plugin_dir));
+ EXPECT_TRUE(PathService::Get(base::DIR_MODULE, &plugin_dir));
FilePath plugin_lib = plugin_dir.Append(library_name);
EXPECT_TRUE(file_util::PathExists(plugin_lib));
FilePath::StringType pepper_plugin = plugin_lib.value();
pepper_plugin.append(FILE_PATH_LITERAL(";application/x-ppapi-tests"));
- launch_arguments_.AppendSwitchNative(switches::kRegisterPepperPlugins,
- pepper_plugin);
- launch_arguments_.AppendSwitchASCII(switches::kAllowNaClSocketAPI,
- "127.0.0.1");
+ command_line->AppendSwitchNative(switches::kRegisterPepperPlugins,
+ pepper_plugin);
+ command_line->AppendSwitchASCII(switches::kAllowNaClSocketAPI, "127.0.0.1");
}
std::string BuildQuery(const std::string& base,
@@ -218,8 +276,14 @@ class PPAPITest : public PPAPITestBase {
class OutOfProcessPPAPITest : public PPAPITest {
public:
OutOfProcessPPAPITest() {
+
+ }
+
+ virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
+ PPAPITest::SetUpCommandLine(command_line);
+
// Run PPAPI out-of-process to exercise proxy implementations.
- launch_arguments_.AppendSwitch(switches::kPpapiOutOfProcess);
+ command_line->AppendSwitch(switches::kPpapiOutOfProcess);
}
};
@@ -227,14 +291,18 @@ class OutOfProcessPPAPITest : public PPAPITest {
class PPAPINaClTest : public PPAPITestBase {
public:
PPAPINaClTest() {
+ }
+
+ virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
+ PPAPITestBase::SetUpCommandLine(command_line);
+
FilePath plugin_lib;
EXPECT_TRUE(PathService::Get(chrome::FILE_NACL_PLUGIN, &plugin_lib));
EXPECT_TRUE(file_util::PathExists(plugin_lib));
// Enable running NaCl outside of the store.
- launch_arguments_.AppendSwitch(switches::kEnableNaCl);
- launch_arguments_.AppendSwitchASCII(switches::kAllowNaClSocketAPI,
- "127.0.0.1");
+ command_line->AppendSwitch(switches::kEnableNaCl);
+ command_line->AppendSwitchASCII(switches::kAllowNaClSocketAPI, "127.0.0.1");
}
// Append the correct mode and testcase string
@@ -248,12 +316,17 @@ class PPAPINaClTest : public PPAPITestBase {
class PPAPINaClTestDisallowedSockets : public PPAPITestBase {
public:
PPAPINaClTestDisallowedSockets() {
+ }
+
+ virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
+ PPAPITestBase::SetUpCommandLine(command_line);
+
FilePath plugin_lib;
EXPECT_TRUE(PathService::Get(chrome::FILE_NACL_PLUGIN, &plugin_lib));
EXPECT_TRUE(file_util::PathExists(plugin_lib));
// Enable running NaCl outside of the store.
- launch_arguments_.AppendSwitch(switches::kEnableNaCl);
+ command_line->AppendSwitch(switches::kEnableNaCl);
}
// Append the correct mode and testcase string
@@ -270,31 +343,31 @@ class PPAPINaClTestDisallowedSockets : public PPAPITestBase {
// Use these macros to run the tests for a specific interface.
// Most interfaces should be tested with both macros.
#define TEST_PPAPI_IN_PROCESS(test_name) \
- TEST_F(PPAPITest, test_name) { \
+ IN_PROC_BROWSER_TEST_F(PPAPITest, test_name) { \
RunTest(STRIP_PREFIXES(test_name)); \
}
#define TEST_PPAPI_OUT_OF_PROCESS(test_name) \
- TEST_F(OutOfProcessPPAPITest, test_name) { \
+ IN_PROC_BROWSER_TEST_F(OutOfProcessPPAPITest, test_name) { \
RunTest(STRIP_PREFIXES(test_name)); \
}
// Similar macros that test over HTTP.
#define TEST_PPAPI_IN_PROCESS_VIA_HTTP(test_name) \
- TEST_F(PPAPITest, test_name) { \
+ IN_PROC_BROWSER_TEST_F(PPAPITest, test_name) { \
RunTestViaHTTP(STRIP_PREFIXES(test_name)); \
}
#define TEST_PPAPI_OUT_OF_PROCESS_VIA_HTTP(test_name) \
- TEST_F(OutOfProcessPPAPITest, test_name) { \
+ IN_PROC_BROWSER_TEST_F(OutOfProcessPPAPITest, test_name) { \
RunTestViaHTTP(STRIP_PREFIXES(test_name)); \
}
// Similar macros that test with WebSocket server
#define TEST_PPAPI_IN_PROCESS_WITH_WS(test_name) \
- TEST_F(PPAPITest, test_name) { \
+ IN_PROC_BROWSER_TEST_F(PPAPITest, test_name) { \
RunTestWithWebSocketServer(STRIP_PREFIXES(test_name)); \
}
#define TEST_PPAPI_OUT_OF_PROCESS_WITH_WS(test_name) \
- TEST_F(OutOfProcessPPAPITest, test_name) { \
+ IN_PROC_BROWSER_TEST_F(OutOfProcessPPAPITest, test_name) { \
RunTestWithWebSocketServer(STRIP_PREFIXES(test_name)); \
}
@@ -307,19 +380,19 @@ class PPAPINaClTestDisallowedSockets : public PPAPITestBase {
// NaCl based PPAPI tests
#define TEST_PPAPI_NACL_VIA_HTTP(test_name) \
- TEST_F(PPAPINaClTest, test_name) { \
+ IN_PROC_BROWSER_TEST_F(PPAPINaClTest, test_name) { \
RunTestViaHTTP(STRIP_PREFIXES(test_name)); \
}
// NaCl based PPAPI tests with disallowed socket API
#define TEST_PPAPI_NACL_VIA_HTTP_DISALLOWED_SOCKETS(test_name) \
- TEST_F(PPAPINaClTestDisallowedSockets, test_name) { \
+ IN_PROC_BROWSER_TEST_F(PPAPINaClTestDisallowedSockets, test_name) { \
RunTestViaHTTP(STRIP_PREFIXES(test_name)); \
}
// NaCl based PPAPI tests with WebSocket server
#define TEST_PPAPI_NACL_VIA_HTTP_WITH_WS(test_name) \
- TEST_F(PPAPINaClTest, test_name) { \
+ IN_PROC_BROWSER_TEST_F(PPAPINaClTest, test_name) { \
RunTestWithWebSocketServer(STRIP_PREFIXES(test_name)); \
}
#endif
@@ -500,7 +573,7 @@ TEST_PPAPI_NACL_VIA_HTTP(PaintAggregator)
// TODO(danakj): http://crbug.com/115286
TEST_PPAPI_IN_PROCESS(DISABLED_Scrollbar)
// http://crbug.com/89961
-TEST_F(OutOfProcessPPAPITest, FAILS_Scrollbar) {
+IN_PROC_BROWSER_TEST_F(OutOfProcessPPAPITest, FAILS_Scrollbar) {
RunTest("Scrollbar");
}
// TODO(danakj): http://crbug.com/115286
@@ -631,10 +704,10 @@ TEST_PPAPI_NACL_VIA_HTTP(FileSystem)
#define MAYBE_OutOfProcessFlashFullscreen FlashFullscreen
#endif
-TEST_F(PPAPITest, MAYBE_FlashFullscreen) {
+IN_PROC_BROWSER_TEST_F(PPAPITest, MAYBE_FlashFullscreen) {
RunTestViaHTTP("FlashFullscreen");
}
-TEST_F(OutOfProcessPPAPITest, MAYBE_OutOfProcessFlashFullscreen) {
+IN_PROC_BROWSER_TEST_F(OutOfProcessPPAPITest, MAYBE_OutOfProcessFlashFullscreen) {
RunTestViaHTTP("FlashFullscreen");
}
@@ -659,17 +732,17 @@ TEST_PPAPI_OUT_OF_PROCESS(FlashClipboard)
// Flaky on Mac + Linux, maybe http://codereview.chromium.org/7094008
// Not implemented out of process: http://crbug.com/106129
-TEST_F(PPAPITest, MAYBE_DirectoryReader) {
+IN_PROC_BROWSER_TEST_F(PPAPITest, MAYBE_DirectoryReader) {
RunTestViaHTTP("DirectoryReader");
}
#if defined(ENABLE_P2P_APIS)
// Flaky. http://crbug.com/84294
-TEST_F(PPAPITest, DISABLED_Transport) {
+IN_PROC_BROWSER_TEST_F(PPAPITest, DISABLED_Transport) {
RunTest("Transport");
}
// http://crbug.com/89961
-TEST_F(OutOfProcessPPAPITest, DISABLED_Transport) {
+IN_PROC_BROWSER_TEST_F(OutOfProcessPPAPITest, DISABLED_Transport) {
RunTestViaHTTP("Transport");
}
#endif // ENABLE_P2P_APIS
@@ -724,7 +797,7 @@ TEST_PPAPI_NACL_VIA_HTTP(MAYBE_NetAddressPrivateUntrusted_GetPort)
TEST_PPAPI_NACL_VIA_HTTP(NetAddressPrivateUntrusted_GetAddress)
// PPB_TCPSocket_Private currently isn't supported in-process.
-TEST_F(OutOfProcessPPAPITest, TCPSocketPrivate) {
+IN_PROC_BROWSER_TEST_F(OutOfProcessPPAPITest, TCPSocketPrivate) {
RunTestViaHTTP("TCPSocketPrivate");
}
@@ -818,50 +891,50 @@ TEST_PPAPI_NACL_VIA_HTTP(View_CreateVisible);
// This test ensures that plugins created in a background tab have their
// initial visibility set to false. We don't bother testing in-process for this
// custom test since the out of process code also exercises in-process.
-TEST_F(OutOfProcessPPAPITest, View_CreateInvisible) {
+
+IN_PROC_BROWSER_TEST_F(OutOfProcessPPAPITest, View_CreateInvisible) {
// Make a second tab in the foreground.
- scoped_refptr<TabProxy> tab(GetActiveTab());
- ASSERT_TRUE(tab.get());
- scoped_refptr<BrowserProxy> browser(tab->GetParentBrowser());
- ASSERT_TRUE(browser.get());
GURL url = GetTestFileUrl("View_CreatedInvisible");
- ASSERT_TRUE(browser->AppendBackgroundTab(url));
-
- // Tab 1 will be the one we appended after the default tab 0.
- RunTestURL(tab, url);
+ browser::NavigateParams params(browser(), url, content::PAGE_TRANSITION_LINK);
+ params.disposition = NEW_BACKGROUND_TAB;
+ ui_test_utils::NavigateToURL(&params);
}
+
// This test messes with tab visibility so is custom.
-TEST_F(OutOfProcessPPAPITest, View_PageHideShow) {
- GURL url = GetTestFileUrl("View_PageHideShow");
- scoped_refptr<TabProxy> tab = GetActiveTab();
- ASSERT_TRUE(tab.get());
- ASSERT_TRUE(tab->NavigateToURLBlockUntilNavigationsComplete(url, 1));
-
- // The plugin will be loaded in the foreground tab and will set the
- // "created" cookie.
- std::string true_str("TRUE");
- std::string progress = WaitUntilCookieNonEmpty(tab.get(), url,
- "TestPageHideShow:Created",
+IN_PROC_BROWSER_TEST_F(OutOfProcessPPAPITest, View_PageHideShow) {
+ // The plugin will be loaded in the foreground tab and will send us a message.
+ TestFinishObserver observer(
+ browser()->GetSelectedWebContents()->GetRenderViewHost(),
TestTimeouts::action_max_timeout_ms());
- ASSERT_EQ(true_str, progress);
+
+ GURL url = GetTestFileUrl("View_PageHideShow");
+ ui_test_utils::NavigateToURL(browser(), url);
+
+ ASSERT_TRUE(observer.WaitForFinish()) << "Test timed out.";
+ EXPECT_STREQ("TestPageHideShow:Created", observer.result().c_str());
+ observer.Reset();
// Make a new tab to cause the original one to hide, this should trigger the
// next phase of the test.
- scoped_refptr<BrowserProxy> browser(tab->GetParentBrowser());
- ASSERT_TRUE(browser.get());
- ASSERT_TRUE(browser->AppendTab(GURL(chrome::kAboutBlankURL)));
+ browser::NavigateParams params(
+ browser(), GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_LINK);
+ params.disposition = NEW_FOREGROUND_TAB;
+ ui_test_utils::NavigateToURL(&params);
// Wait until the test acks that it got hidden.
- progress = WaitUntilCookieNonEmpty(tab.get(), url, "TestPageHideShow:Hidden",
- TestTimeouts::action_max_timeout_ms());
- ASSERT_EQ(true_str, progress);
+ ASSERT_TRUE(observer.WaitForFinish()) << "Test timed out.";
+ EXPECT_STREQ("TestPageHideShow:Hidden", observer.result().c_str());
+
+ // Wait for the test completion event.
+ observer.Reset();
// Switch back to the test tab.
- ASSERT_TRUE(browser->ActivateTab(0));
+ browser()->ActivateTabAt(0, true);
- // Wait for the test completion event.
- RunTestURL(tab, url);
+ ASSERT_TRUE(observer.WaitForFinish()) << "Test timed out.";
+ EXPECT_STREQ("PASS", observer.result().c_str());
}
+
TEST_PPAPI_IN_PROCESS(View_SizeChange);
TEST_PPAPI_OUT_OF_PROCESS(View_SizeChange);
TEST_PPAPI_NACL_VIA_HTTP(View_SizeChange);
diff --git a/ppapi/tests/test_view.cc b/ppapi/tests/test_view.cc
index 3889285..6a8e748 100644
--- a/ppapi/tests/test_view.cc
+++ b/ppapi/tests/test_view.cc
@@ -93,9 +93,8 @@ std::string TestView::TestPageHideShow() {
ASSERT_FALSE(page_visibility_log_.empty());
ASSERT_TRUE(page_visibility_log_[0]);
- // Now that we're alive, set a cookie so the UI test knows it can change our
- // visibility.
- instance_->SetCookie("TestPageHideShow:Created", "TRUE");
+ // Now that we're alive, tell the test knows it can change our visibility.
+ instance_->ReportProgress("TestPageHideShow:Created");
// Wait until we get a hide event, being careful to handle spurious
// notifications of ViewChanged.
@@ -116,8 +115,8 @@ std::string TestView::TestPageHideShow() {
"tab, waiting 2 more secs, and closing the new tab.";
}
- // Set a cookie so the UI test knows it can show us again.
- instance_->SetCookie("TestPageHideShow:Hidden", "TRUE");
+ // Tell the test so it can show us again.
+ instance_->ReportProgress("TestPageHideShow:Hidden");
// Wait until we get a show event.
begin_time = pp::Module::Get()->core()->GetTime();
diff --git a/ppapi/tests/testing_instance.cc b/ppapi/tests/testing_instance.cc
index 58e0890..22dfccb 100644
--- a/ppapi/tests/testing_instance.cc
+++ b/ppapi/tests/testing_instance.cc
@@ -29,7 +29,6 @@ TestingInstance::TestingInstance(PP_Instance instance)
: pp::InstancePrivate(instance),
#endif
current_case_(NULL),
- progress_cookie_number_(0),
executed_tests_(false),
nacl_mode_(false) {
callback_factory_.Initialize(this);
@@ -233,10 +232,10 @@ void TestingInstance::LogHTML(const std::string& html) {
void TestingInstance::ReportProgress(const std::string& progress_value) {
// Use streams since nacl doesn't compile base yet (for StringPrintf).
- std::ostringstream cookie_name;
- cookie_name << "PPAPI_PROGRESS_" << progress_cookie_number_;
- SetCookie(cookie_name.str(), progress_value);
- progress_cookie_number_++;
+ std::ostringstream script;
+ script << "window.domAutomationController.setAutomationId(0);" <<
+ "window.domAutomationController.send(\"" << progress_value << "\")";
+ EvalScript(script.str());
}
class Module : public pp::Module {
diff --git a/ppapi/tests/testing_instance.h b/ppapi/tests/testing_instance.h
index 7b05174..55c7e3d 100644
--- a/ppapi/tests/testing_instance.h
+++ b/ppapi/tests/testing_instance.h
@@ -19,20 +19,19 @@ class TestCase;
// How signaling works:
//
-// We want to signal to the Chrome UI test harness
+// We want to signal to the Chrome browser test harness
// (chrome/test/ui/ppapi_uitest.cc) that we're making progress and when we're
-// done. The easiest thing in the UI test infrastructure is to wait for a
-// cookie to become nonempty. We don't want to have a big wait for all tests in
-// a TestCase since they can take a while and it might timeout. So we set a
-// series of cookies with an incrementing number in the name.
+// done. This is done using the DOM controlller. The browser test waits for a
+// message from it. We don't want to have a big wait for all tests in a TestCase
+// since they can take a while and it might timeout. So we send it pings
+// between each test to tell it that we're still running tests and aren't stuck.
//
-// If the value of the cookie is "..." then that tells the test runner that
-// the test is progressing. It then waits for the next numbered cookie until
-// it either times out or the value is something other than "...". In this
-// case, the value will be either "PASS" or "FAIL [optional message]"
-// corresponding to the outcome of the entire test case. Timeout will be
-// treated just like a failure of the entire test case and the test will be
-// terminated.
+// If the value of the message is "..." then that tells the test runner that
+// the test is progressing. It then waits for the next message until it either
+// times out or the value is something other than "...". In this case, the value
+// will be either "PASS" or "FAIL [optional message]" corresponding to the
+// outcome of the entire test case. Timeout will be treated just like a failure
+// of the entire test case and the test will be terminated.
//
// In trusted builds, we use InstancePrivate and allow tests that use
// synchronous scripting. NaCl does not support synchronous scripting.
@@ -89,6 +88,8 @@ pp::InstancePrivate {
// Sets the given cookie in the current document.
void SetCookie(const std::string& name, const std::string& value);
+ void ReportProgress(const std::string& progress_value);
+
private:
void ExecuteTests(int32_t unused);
@@ -115,8 +116,6 @@ pp::InstancePrivate {
// Appends the given HTML string to the console in the document.
void LogHTML(const std::string& html);
- void ReportProgress(const std::string& progress_value);
-
pp::CompletionCallbackFactory<TestingInstance> callback_factory_;
// Owning pointer to the current test case. Valid after Init has been called.
@@ -126,10 +125,6 @@ pp::InstancePrivate {
// runs only tests whose name contains test_filter_ as a substring.
std::string test_filter_;
- // The current step we're on starting at 0. This is incremented every time we
- // report progress via a cookie. See comment above the class.
- int progress_cookie_number_;
-
// Set once the tests are run so we know not to re-run when the view is sized.
bool executed_tests_;