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

Side by Side Diff: services/window_manager/window_manager_apptest.cc

Issue 996533002: Remove hardcoded tests URLs from apptests. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Edit Created 5 years, 9 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
« no previous file with comments | « services/view_manager/view_manager_service_apptest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/run_loop.h" 6 #include "base/run_loop.h"
7 #include "mojo/public/cpp/application/application_delegate.h" 7 #include "mojo/public/cpp/application/application_delegate.h"
8 #include "mojo/public/cpp/application/application_impl.h" 8 #include "mojo/public/cpp/application/application_impl.h"
9 #include "mojo/public/cpp/application/application_test_base.h" 9 #include "mojo/public/cpp/application/application_test_base.h"
10 #include "mojo/public/cpp/application/service_provider_impl.h" 10 #include "mojo/public/cpp/application/service_provider_impl.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 101
102 WindowManagerPtr window_manager_; 102 WindowManagerPtr window_manager_;
103 TestApplication test_application_; 103 TestApplication test_application_;
104 104
105 private: 105 private:
106 MOJO_DISALLOW_COPY_AND_ASSIGN(WindowManagerApplicationTest); 106 MOJO_DISALLOW_COPY_AND_ASSIGN(WindowManagerApplicationTest);
107 }; 107 };
108 108
109 TEST_F(WindowManagerApplicationTest, Embed) { 109 TEST_F(WindowManagerApplicationTest, Embed) {
110 EXPECT_EQ(nullptr, test_application_.root()); 110 EXPECT_EQ(nullptr, test_application_.root());
111 EmbedApplicationWithURL("mojo:window_manager_apptests"); 111 EmbedApplicationWithURL(application_impl()->url());
112 EXPECT_NE(nullptr, test_application_.root()); 112 EXPECT_NE(nullptr, test_application_.root());
113 } 113 }
114 114
115 struct BoolCallback { 115 struct BoolCallback {
116 BoolCallback(bool* bool_value, base::RunLoop* run_loop) 116 BoolCallback(bool* bool_value, base::RunLoop* run_loop)
117 : bool_value(bool_value), run_loop(run_loop) {} 117 : bool_value(bool_value), run_loop(run_loop) {}
118 118
119 void Run(bool value) const { 119 void Run(bool value) const {
120 *bool_value = value; 120 *bool_value = value;
121 run_loop->Quit(); 121 run_loop->Quit();
122 } 122 }
123 123
124 bool* bool_value; 124 bool* bool_value;
125 base::RunLoop* run_loop; 125 base::RunLoop* run_loop;
126 }; 126 };
127 127
128 TEST_F(WindowManagerApplicationTest, SetCaptureFailsFromNonVM) { 128 TEST_F(WindowManagerApplicationTest, SetCaptureFailsFromNonVM) {
129 EmbedApplicationWithURL("mojo:window_manager_apptests"); 129 EmbedApplicationWithURL(application_impl()->url());
130 bool callback_value = true; 130 bool callback_value = true;
131 base::RunLoop run_loop; 131 base::RunLoop run_loop;
132 window_manager_->SetCapture(test_application_.root()->id(), 132 window_manager_->SetCapture(test_application_.root()->id(),
133 BoolCallback(&callback_value, &run_loop)); 133 BoolCallback(&callback_value, &run_loop));
134 run_loop.Run(); 134 run_loop.Run();
135 // This call only succeeds for WindowManager connections from the ViewManager. 135 // This call only succeeds for WindowManager connections from the ViewManager.
136 EXPECT_FALSE(callback_value); 136 EXPECT_FALSE(callback_value);
137 } 137 }
138 138
139 TEST_F(WindowManagerApplicationTest, FocusWindowFailsFromNonVM) { 139 TEST_F(WindowManagerApplicationTest, FocusWindowFailsFromNonVM) {
140 EmbedApplicationWithURL("mojo:window_manager_apptests"); 140 EmbedApplicationWithURL(application_impl()->url());
141 bool callback_value = true; 141 bool callback_value = true;
142 base::RunLoop run_loop; 142 base::RunLoop run_loop;
143 window_manager_->FocusWindow(test_application_.root()->id(), 143 window_manager_->FocusWindow(test_application_.root()->id(),
144 BoolCallback(&callback_value, &run_loop)); 144 BoolCallback(&callback_value, &run_loop));
145 run_loop.Run(); 145 run_loop.Run();
146 // This call only succeeds for WindowManager connections from the ViewManager. 146 // This call only succeeds for WindowManager connections from the ViewManager.
147 EXPECT_FALSE(callback_value); 147 EXPECT_FALSE(callback_value);
148 } 148 }
149 149
150 TEST_F(WindowManagerApplicationTest, ActivateWindowFailsFromNonVM) { 150 TEST_F(WindowManagerApplicationTest, ActivateWindowFailsFromNonVM) {
151 EmbedApplicationWithURL("mojo:window_manager_apptests"); 151 EmbedApplicationWithURL(application_impl()->url());
152 bool callback_value = true; 152 bool callback_value = true;
153 base::RunLoop run_loop; 153 base::RunLoop run_loop;
154 window_manager_->ActivateWindow(test_application_.root()->id(), 154 window_manager_->ActivateWindow(test_application_.root()->id(),
155 BoolCallback(&callback_value, &run_loop)); 155 BoolCallback(&callback_value, &run_loop));
156 run_loop.Run(); 156 run_loop.Run();
157 // This call only succeeds for WindowManager connections from the ViewManager. 157 // This call only succeeds for WindowManager connections from the ViewManager.
158 EXPECT_FALSE(callback_value); 158 EXPECT_FALSE(callback_value);
159 } 159 }
160 160
161 struct FocusedAndActiveViewsCallback { 161 struct FocusedAndActiveViewsCallback {
(...skipping 14 matching lines...) Expand all
176 run_loop->Quit(); 176 run_loop->Quit();
177 } 177 }
178 178
179 uint32* capture_view_id; 179 uint32* capture_view_id;
180 uint32* focused_view_id; 180 uint32* focused_view_id;
181 uint32* active_view_id; 181 uint32* active_view_id;
182 base::RunLoop* run_loop; 182 base::RunLoop* run_loop;
183 }; 183 };
184 184
185 TEST_F(WindowManagerApplicationTest, GetFocusedAndActiveViewsFailsWithoutFC) { 185 TEST_F(WindowManagerApplicationTest, GetFocusedAndActiveViewsFailsWithoutFC) {
186 EmbedApplicationWithURL("mojo:window_manager_apptests"); 186 EmbedApplicationWithURL(application_impl()->url());
187 uint32 capture_view_id = -1; 187 uint32 capture_view_id = -1;
188 uint32 focused_view_id = -1; 188 uint32 focused_view_id = -1;
189 uint32 active_view_id = -1; 189 uint32 active_view_id = -1;
190 base::RunLoop run_loop; 190 base::RunLoop run_loop;
191 191
192 WindowManagerObserverPtr observer; 192 WindowManagerObserverPtr observer;
193 scoped_ptr<TestWindowManagerObserver> window_manager_observer( 193 scoped_ptr<TestWindowManagerObserver> window_manager_observer(
194 new TestWindowManagerObserver(GetProxy(&observer))); 194 new TestWindowManagerObserver(GetProxy(&observer)));
195 195
196 window_manager_->GetFocusedAndActiveViews( 196 window_manager_->GetFocusedAndActiveViews(
197 observer.Pass(), 197 observer.Pass(),
198 FocusedAndActiveViewsCallback(&capture_view_id, 198 FocusedAndActiveViewsCallback(&capture_view_id,
199 &focused_view_id, 199 &focused_view_id,
200 &active_view_id, 200 &active_view_id,
201 &run_loop)); 201 &run_loop));
202 run_loop.Run(); 202 run_loop.Run();
203 // This call fails if the WindowManager does not have a FocusController. 203 // This call fails if the WindowManager does not have a FocusController.
204 EXPECT_EQ(0u, capture_view_id); 204 EXPECT_EQ(0u, capture_view_id);
205 EXPECT_EQ(0u, focused_view_id); 205 EXPECT_EQ(0u, focused_view_id);
206 EXPECT_EQ(0u, active_view_id); 206 EXPECT_EQ(0u, active_view_id);
207 } 207 }
208 208
209 // TODO(msw): Write tests exercising other WindowManager functionality. 209 // TODO(msw): Write tests exercising other WindowManager functionality.
210 210
211 } // namespace 211 } // namespace
212 } // namespace mojo 212 } // namespace mojo
OLDNEW
« no previous file with comments | « services/view_manager/view_manager_service_apptest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698