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

Unified Diff: chrome/test/media_router/media_router_base_browsertest.cc

Issue 595663002: Put chromoting isolate targets under chromoting_swarm_tests=1 GYP variable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/media_router/media_router_base_browsertest.cc
diff --git a/chrome/test/media_router/media_router_base_browsertest.cc b/chrome/test/media_router/media_router_base_browsertest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a35ead3fd5fa1360db00c345e37c94ff680c0592
--- /dev/null
+++ b/chrome/test/media_router/media_router_base_browsertest.cc
@@ -0,0 +1,131 @@
+// Copyright 2015 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.
+
+#include "chrome/test/media_router/media_router_base_browsertest.h"
+
+#include "base/bind.h"
+#include "base/command_line.h"
+#include "base/path_service.h"
+#include "base/timer/elapsed_timer.h"
+#include "chrome/browser/extensions/unpacked_installer.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/chrome_switches.h"
+#include "chrome/test/base/ui_test_utils.h"
+#include "content/public/common/content_switches.h"
+#include "content/public/test/test_utils.h"
+#include "extensions/browser/process_manager.h"
+
+namespace {
+// Command line argument to specify CRX extension location.
+const char kExtensionCrx[] = "extension-crx";
+// Command line argument to specify unpacked extension location.
+const char kExtensionUnpacked[] = "extension-unpacked";
+} // namespace
+
+namespace media_router {
+
+MediaRouterBaseBrowserTest::MediaRouterBaseBrowserTest()
+ : extension_host_created_(false) {
+ base::CommandLine::ForCurrentProcess()->AppendSwitch(
+ switches::kEnableMediaRouter);
+ base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
+ switches::kEnableBlinkFeatures, "Presentation");
+}
+
+MediaRouterBaseBrowserTest::~MediaRouterBaseBrowserTest() {
+}
+
+void MediaRouterBaseBrowserTest::SetUp() {
+ ParseCommandLine();
+ ExtensionBrowserTest::SetUp();
+}
+
+void MediaRouterBaseBrowserTest::TearDown() {
+ ExtensionBrowserTest::TearDown();
+}
+
+void MediaRouterBaseBrowserTest::SetUpOnMainThread() {
+ extensions::ProcessManager* process_manager =
+ extensions::ProcessManager::Get(browser()->profile());
+ DCHECK(process_manager);
+ process_manager->AddObserver(this);
+ InstallAndEnableMRExtension();
+
+ // Wait until extension host has been created or timeout.
+ Wait(base::TimeDelta::FromSeconds(30), base::TimeDelta::FromSeconds(1),
+ base::Bind(&MediaRouterBaseBrowserTest::is_extension_host_created,
+ base::Unretained(this)));
+}
+
+void MediaRouterBaseBrowserTest::TearDownOnMainThread() {
+ UninstallMRExtension();
+ extensions::ProcessManager* process_manager =
+ extensions::ProcessManager::Get(browser()->profile());
+ DCHECK(process_manager);
+ process_manager->RemoveObserver(this);
+}
+
+void MediaRouterBaseBrowserTest::InstallAndEnableMRExtension() {
+ if (is_unpacked()) {
+ const extensions::Extension* extension = LoadExtension(extension_unpacked_);
+ extension_id_ = extension->id();
+ } else {
+ NOTIMPLEMENTED();
+ }
+}
+
+void MediaRouterBaseBrowserTest::UninstallMRExtension() {
+ if (!extension_id_.empty()) {
+ UninstallExtension(extension_id_);
+ }
+}
+
+void MediaRouterBaseBrowserTest::Wait(
+ base::TimeDelta timeout, base::TimeDelta interval,
+ const base::Callback<bool(void)>& callback) {
+ base::ElapsedTimer timer;
+ while (!callback.Run() && timer.Elapsed() < timeout) {
+ base::RunLoop run_loop;
+ base::MessageLoop::current()->PostDelayedTask(
+ FROM_HERE, run_loop.QuitClosure(), interval);
+ run_loop.Run();
+ }
+}
+
+void MediaRouterBaseBrowserTest::Wait(base::TimeDelta timeout) {
+ base::RunLoop run_loop;
+ base::MessageLoop::current()->PostDelayedTask(
+ FROM_HERE, run_loop.QuitClosure(), timeout);
+ run_loop.Run();
+}
+
+void MediaRouterBaseBrowserTest::OnBackgroundHostCreated(
+ extensions::ExtensionHost* host) {
+ extension_host_created_ = true;
+ DVLOG(0) << "Host created";
+}
+
+void MediaRouterBaseBrowserTest::ParseCommandLine() {
+ DVLOG(0) << "ParseCommandLine";
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+
+ extension_crx_ = command_line->GetSwitchValuePath(kExtensionCrx);
+ extension_unpacked_ = command_line->GetSwitchValuePath(kExtensionUnpacked);
+
+ // Check if there is mr_extension folder under PRODUCT_DIR folder.
+ if (extension_crx_.empty() && extension_unpacked_.empty()) {
+ base::FilePath base_dir;
+ ASSERT_TRUE(PathService::Get(base::DIR_EXE, &base_dir));
+ base::FilePath extension_path =
+ base_dir.Append(FILE_PATH_LITERAL("mr_extension/"));
+ if (PathExists(extension_path)) {
+ extension_unpacked_ = extension_path;
+ }
+ }
+
+ // Exactly one of these two arguments should be provided.
+ ASSERT_NE(extension_crx_.empty(), extension_unpacked_.empty());
+}
+
+} // namespace media_router
« no previous file with comments | « chrome/test/media_router/media_router_base_browsertest.h ('k') | chrome/test/media_router/media_router_e2e_browsertest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698