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

Side by Side Diff: blimp/engine/browser_tests/blimp_browser_test.cc

Issue 2320923002: Add a full Blimp integration test. (Closed)
Patch Set: Fix build break with chrome embedder Created 4 years, 3 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "blimp/engine/browser_tests/blimp_browser_test.h" 5 #include "blimp/engine/browser_tests/blimp_browser_test.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/base_switches.h" 9 #include "base/base_switches.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 16 matching lines...) Expand all
27 #include "content/public/common/url_constants.h" 27 #include "content/public/common/url_constants.h"
28 #include "content/public/test/test_utils.h" 28 #include "content/public/test/test_utils.h"
29 29
30 namespace blimp { 30 namespace blimp {
31 namespace { 31 namespace {
32 const char kTestDataFilePath[] = "blimp/test/data"; 32 const char kTestDataFilePath[] = "blimp/test/data";
33 const char kClientAuthTokenFilePath[] = "blimp/test/data/test_client_token"; 33 const char kClientAuthTokenFilePath[] = "blimp/test/data/test_client_token";
34 const char kClientAuthToken[] = "MyVoiceIsMyPassport"; 34 const char kClientAuthToken[] = "MyVoiceIsMyPassport";
35 } // namespace 35 } // namespace
36 36
37
38 BlimpBrowserTest::BlimpBrowserTest() 37 BlimpBrowserTest::BlimpBrowserTest()
39 : completion_event_(base::WaitableEvent::ResetPolicy::MANUAL, 38 : engine_port_(0),
39 completion_event_(base::WaitableEvent::ResetPolicy::MANUAL,
40 base::WaitableEvent::InitialState::NOT_SIGNALED) { 40 base::WaitableEvent::InitialState::NOT_SIGNALED) {
41 CreateTestServer(base::FilePath(FILE_PATH_LITERAL(kTestDataFilePath))); 41 CreateTestServer(base::FilePath(FILE_PATH_LITERAL(kTestDataFilePath)));
42 } 42 }
43 43
44 BlimpBrowserTest::~BlimpBrowserTest() {} 44 BlimpBrowserTest::~BlimpBrowserTest() {}
45 45
46 void BlimpBrowserTest::RunUntilCompletion() { 46 void BlimpBrowserTest::RunUntilCompletion() {
47 while (!completion_event_.IsSignaled()) { 47 while (!completion_event_.IsSignaled()) {
48 content::RunAllPendingInMessageLoop(content::BrowserThread::IO); 48 content::RunAllPendingInMessageLoop(content::BrowserThread::IO);
49 content::RunAllPendingInMessageLoop(content::BrowserThread::UI); 49 content::RunAllPendingInMessageLoop(content::BrowserThread::UI);
50 } 50 }
51 completion_event_.Reset(); 51 completion_event_.Reset();
52 } 52 }
53 53
54 void BlimpBrowserTest::AllowUIWaits() {
55 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
56 allow_ui_waits_ =
57 base::MakeUnique<base::ThreadRestrictions::ScopedAllowWait>();
58 }
59
54 void BlimpBrowserTest::SignalCompletion() { 60 void BlimpBrowserTest::SignalCompletion() {
55 completion_event_.Signal(); 61 completion_event_.Signal();
56 } 62 }
57 63
58 void BlimpBrowserTest::SetUp() { 64 void BlimpBrowserTest::SetUp() {
59 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 65 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
60 SetUpCommandLine(command_line); 66 SetUpCommandLine(command_line);
61 BrowserTestBase::SetUp(); 67 BrowserTestBase::SetUp();
62 } 68 }
63 69
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 101
96 void BlimpBrowserTest::SetUpOnMainThread() { 102 void BlimpBrowserTest::SetUpOnMainThread() {
97 // Get the connection's port number across the IO/UI thread boundary. 103 // Get the connection's port number across the IO/UI thread boundary.
98 GetEngineSession()->GetEnginePortForTesting(base::Bind( 104 GetEngineSession()->GetEnginePortForTesting(base::Bind(
99 &BlimpBrowserTest::OnGetEnginePortCompletion, base::Unretained(this))); 105 &BlimpBrowserTest::OnGetEnginePortCompletion, base::Unretained(this)));
100 106
101 RunUntilCompletion(); 107 RunUntilCompletion();
102 } 108 }
103 109
104 void BlimpBrowserTest::TearDownOnMainThread() { 110 void BlimpBrowserTest::TearDownOnMainThread() {
111 allow_ui_waits_.reset();
105 base::MessageLoop::current()->QuitWhenIdle(); 112 base::MessageLoop::current()->QuitWhenIdle();
106 } 113 }
107 114
108 void BlimpBrowserTest::RunTestOnMainThreadLoop() { 115 void BlimpBrowserTest::RunTestOnMainThreadLoop() {
109 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 116 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
110 117
111 SetUpOnMainThread(); 118 SetUpOnMainThread();
112 RunTestOnMainThread(); 119 RunTestOnMainThread();
113 TearDownOnMainThread(); 120 TearDownOnMainThread();
114 121
115 for (content::RenderProcessHost::iterator i( 122 for (content::RenderProcessHost::iterator i(
116 content::RenderProcessHost::AllHostsIterator()); 123 content::RenderProcessHost::AllHostsIterator());
117 !i.IsAtEnd(); i.Advance()) { 124 !i.IsAtEnd(); i.Advance()) {
118 i.GetCurrentValue()->FastShutdownIfPossible(); 125 i.GetCurrentValue()->FastShutdownIfPossible();
119 } 126 }
120 } 127 }
121 128
122 void BlimpBrowserTest::OnGetEnginePortCompletion(uint16_t port) { 129 void BlimpBrowserTest::OnGetEnginePortCompletion(uint16_t port) {
123 engine_port_ = port; 130 engine_port_ = port;
124 SignalCompletion(); 131 SignalCompletion();
125 } 132 }
126 133
127 } // namespace blimp 134 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/engine/browser_tests/blimp_browser_test.h ('k') | blimp/engine/browser_tests/blimp_contents_view_readback_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698