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

Unified Diff: blimp/test/blimp_browser_test.cc

Issue 1929723002: [Blimp] Adds blimp engine browser test framework and LoadUrl test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addresses comments and rebases Created 4 years, 8 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: blimp/test/blimp_browser_test.cc
diff --git a/blimp/test/blimp_browser_test.cc b/blimp/test/blimp_browser_test.cc
new file mode 100644
index 0000000000000000000000000000000000000000..56d9ed15034697c53c050ec246ec078dbc597235
--- /dev/null
+++ b/blimp/test/blimp_browser_test.cc
@@ -0,0 +1,91 @@
+// Copyright 2016 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 "blimp/test/blimp_browser_test.h"
+
+#include "base/base_switches.h"
+#include "base/command_line.h"
+#include "base/files/file_path.h"
+#include "base/memory/ptr_util.h"
+#include "base/message_loop/message_loop.h"
+#include "base/run_loop.h"
+#include "blimp/client/app/blimp_client_switches.h"
+#include "blimp/client/session/assignment_source.h"
+#include "blimp/engine/app/blimp_engine_config.h"
+#include "blimp/engine/app/switches.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/render_process_host.h"
+#include "content/public/common/url_constants.h"
+#include "ui/gl/gl_switches.h"
+
+namespace blimp {
+
+BlimpBrowserTest::BlimpBrowserTest() {
+ base::FilePath test_data(FILE_PATH_LITERAL("blimp/engine/test/data"));
Kevin M 2016/05/02 21:32:39 Path should be a const char* kConstant
haibinlu 2016/05/03 19:32:43 Done.
+ CreateTestServer(test_data);
+}
+
+BlimpBrowserTest::~BlimpBrowserTest() {}
+
+void BlimpBrowserTest::SetUp() {
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+ SetUpCommandLine(command_line);
+ BrowserTestBase::SetUp();
+}
+
+void BlimpBrowserTest::SetUpOnMainThread() {}
+
+void BlimpBrowserTest::TearDownOnMainThread() {
+ content::BrowserThread::GetMessageLoopProxyForThread(
+ content::BrowserThread::UI)
+ ->PostTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
+}
+
+void BlimpBrowserTest::SetUpCommandLine(base::CommandLine* command_line) {
+ command_line->AppendSwitchASCII(::switches::kVModule, "blimp*=2");
+ command_line->AppendSwitchASCII(blimp::switches::kEnginePort, "25567");
Brian Goldman 2016/05/02 16:48:58 Is this port guaranteed available on the environme
haibinlu 2016/05/02 18:36:27 It should be. we have been using static port test
Kevin M 2016/05/02 21:32:39 I think this introduces a flakiness risk for the w
haibinlu 2016/05/03 19:32:43 ah, my bad. both tcp_transport_unittest and tcp_se
+
+ // Engine switches
Kevin M 2016/05/02 21:32:39 I don't think the engine and client should be sha
haibinlu 2016/05/03 19:32:43 what is the alternative way to provide these args?
+ blimp::engine::SetUpCommandLine(command_line);
+ command_line->AppendSwitchASCII(blimp::engine::kClientToken,
+ blimp::client::kDummyClientToken);
+
+ // Client switches
+ // Client's AssignmentSource uses engine IP&port from command line and
+ // defaults to TCP client.
+ command_line->AppendSwitchASCII(blimp::switches::kEngineIP, "127.0.0.1");
+ command_line->AppendSwitchASCII(blimp::switches::kEngineTransport, "tcp");
+}
+
+void BlimpBrowserTest::RunTestOnMainThreadLoop() {
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+
+ // Pump startup related events.
+ base::MessageLoop::current()->RunUntilIdle();
+
+ SetUpOnMainThread();
+ RunTestOnMainThread();
+ TearDownOnMainThread();
+
+ for (content::RenderProcessHost::iterator i(
+ content::RenderProcessHost::AllHostsIterator());
+ !i.IsAtEnd(); i.Advance()) {
+ i.GetCurrentValue()->FastShutdownIfPossible();
+ }
+}
+
+void BlimpBrowserTest::RunAsynchronousTest() {
+ base::MessageLoop::ScopedNestableTaskAllower nestable_allower(
+ base::MessageLoop::current());
+ EXPECT_FALSE(run_loop_);
+ run_loop_ = base::WrapUnique(new base::RunLoop());
+ run_loop_->Run();
+ run_loop_ = nullptr;
+}
+
+void BlimpBrowserTest::FinishAsynchronousTest() {
+ run_loop_->Quit();
+}
+
+} // namespace blimp

Powered by Google App Engine
This is Rietveld 408576698