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

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

Issue 781603002: Port even more FocusController tests. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Initialize my member variables. Created 6 years 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "services/window_manager/focus_controller.h" 5 #include "services/window_manager/focus_controller.h"
6 6
7 #include "mojo/converters/geometry/geometry_type_converters.h" 7 #include "mojo/converters/geometry/geometry_type_converters.h"
8 #include "services/window_manager/basic_focus_rules.h" 8 #include "services/window_manager/basic_focus_rules.h"
9 #include "services/window_manager/focus_controller_observer.h" 9 #include "services/window_manager/focus_controller_observer.h"
10 #include "services/window_manager/view_event_dispatcher.h" 10 #include "services/window_manager/view_event_dispatcher.h"
11 #include "services/window_manager/view_targeter.h" 11 #include "services/window_manager/view_targeter.h"
12 #include "services/window_manager/window_manager_test_util.h" 12 #include "services/window_manager/window_manager_test_util.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "ui/events/test/event_generator.h" 14 #include "ui/events/test/event_generator.h"
15 #include "ui/gfx/geometry/rect.h" 15 #include "ui/gfx/geometry/rect.h"
16 16
17 namespace mojo { 17 namespace mojo {
18 18
19 // Counts the number of events that occur. 19 // Counts the number of events that occur.
20 class FocusNotificationObserver : public FocusControllerObserver { 20 class FocusNotificationObserver : public FocusControllerObserver {
21 public: 21 public:
22 FocusNotificationObserver() 22 FocusNotificationObserver()
23 : activation_changed_count_(0), 23 : activation_changed_count_(0),
24 focus_changed_count_(0), 24 focus_changed_count_(0),
25 reactivation_count_(0), 25 reactivation_count_(0),
26 reactivation_requested_window_(NULL), 26 reactivation_requested_view_(NULL),
27 reactivation_actual_window_(NULL) {} 27 reactivation_actual_view_(NULL) {}
28 ~FocusNotificationObserver() override {} 28 ~FocusNotificationObserver() override {}
29 29
30 void ExpectCounts(int activation_changed_count, int focus_changed_count) { 30 void ExpectCounts(int activation_changed_count, int focus_changed_count) {
31 EXPECT_EQ(activation_changed_count, activation_changed_count_); 31 EXPECT_EQ(activation_changed_count, activation_changed_count_);
32 EXPECT_EQ(focus_changed_count, focus_changed_count_); 32 EXPECT_EQ(focus_changed_count, focus_changed_count_);
33 } 33 }
34 int reactivation_count() const { return reactivation_count_; } 34 int reactivation_count() const { return reactivation_count_; }
35 View* reactivation_requested_window() const { 35 View* reactivation_requested_view() const {
36 return reactivation_requested_window_; 36 return reactivation_requested_view_;
37 } 37 }
38 View* reactivation_actual_window() const { 38 View* reactivation_actual_view() const {
39 return reactivation_actual_window_; 39 return reactivation_actual_view_;
40 } 40 }
41 41
42 protected: 42 protected:
43 // Overridden from FocusControllerObserver: 43 // Overridden from FocusControllerObserver:
44 void OnViewActivated(View* gained_active, View* lost_active) override { 44 void OnViewActivated(View* gained_active, View* lost_active) override {
45 ++activation_changed_count_; 45 ++activation_changed_count_;
46 } 46 }
47 47
48 void OnViewFocused(View* gained_focus, View* lost_focus) override { 48 void OnViewFocused(View* gained_focus, View* lost_focus) override {
49 ++focus_changed_count_; 49 ++focus_changed_count_;
50 } 50 }
51 51
52 void OnAttemptToReactivateView(View* request_active, 52 void OnAttemptToReactivateView(View* request_active,
53 View* actual_active) override { 53 View* actual_active) override {
54 ++reactivation_count_; 54 ++reactivation_count_;
55 reactivation_requested_window_ = request_active; 55 reactivation_requested_view_ = request_active;
56 reactivation_actual_window_ = actual_active; 56 reactivation_actual_view_ = actual_active;
57 } 57 }
58 58
59 private: 59 private:
60 int activation_changed_count_; 60 int activation_changed_count_;
61 int focus_changed_count_; 61 int focus_changed_count_;
62 int reactivation_count_; 62 int reactivation_count_;
63 View* reactivation_requested_window_; 63 View* reactivation_requested_view_;
64 View* reactivation_actual_window_; 64 View* reactivation_actual_view_;
65 65
66 DISALLOW_COPY_AND_ASSIGN(FocusNotificationObserver); 66 DISALLOW_COPY_AND_ASSIGN(FocusNotificationObserver);
67 }; 67 };
68 68
69 class ViewDestroyer {
70 public:
71 virtual View* GetDestroyedView() = 0;
72
73 protected:
74 virtual ~ViewDestroyer() {}
75 };
76
77 // FocusNotificationObserver that keeps track of whether it was notified about
78 // activation changes or focus changes with a destroyed view.
79 class RecordingFocusNotificationObserver : public FocusNotificationObserver {
80 public:
81 RecordingFocusNotificationObserver(FocusController* focus_controller,
82 ViewDestroyer* destroyer)
83 : focus_controller_(focus_controller),
84 destroyer_(destroyer),
85 was_notified_with_destroyed_view_(false) {
86 focus_controller_->AddObserver(this);
87 }
88 ~RecordingFocusNotificationObserver() override {
89 focus_controller_->RemoveObserver(this);
90 }
91
92 bool was_notified_with_destroyed_view() const {
93 return was_notified_with_destroyed_view_;
94 }
95
96 // Overridden from FocusNotificationObserver:
97 void OnViewActivated(View* gained_active, View* lost_active) override {
98 if (lost_active && lost_active == destroyer_->GetDestroyedView())
99 was_notified_with_destroyed_view_ = true;
100 }
101
102 void OnViewFocused(View* gained_focus, View* lost_focus) override {
103 if (lost_focus && lost_focus == destroyer_->GetDestroyedView())
104 was_notified_with_destroyed_view_ = true;
105 }
106
107 private:
108 mojo::FocusController* focus_controller_;
109
110 // Not owned.
111 ViewDestroyer* destroyer_;
112
113 // Whether the observer was notified about the loss of activation or the
114 // loss of focus with a view already destroyed by |destroyer_| as the
115 // |lost_active| or |lost_focus| parameter.
116 bool was_notified_with_destroyed_view_;
117
118 DISALLOW_COPY_AND_ASSIGN(RecordingFocusNotificationObserver);
119 };
120
121 class DestroyOnLoseActivationFocusNotificationObserver
122 : public FocusNotificationObserver,
123 public ViewDestroyer {
124 public:
125 DestroyOnLoseActivationFocusNotificationObserver(
126 FocusController* focus_controller,
127 View* view_to_destroy)
128 : focus_controller_(focus_controller),
129 view_to_destroy_(view_to_destroy),
130 did_destroy_(false) {
131 focus_controller_->AddObserver(this);
132 }
133 ~DestroyOnLoseActivationFocusNotificationObserver() override {
134 focus_controller_->RemoveObserver(this);
135 }
136
137 // Overridden from FocusNotificationObserver:
138 void OnViewActivated(View* gained_active, View* lost_active) override {
139 if (view_to_destroy_ && lost_active == view_to_destroy_) {
140 view_to_destroy_->Destroy();
141 did_destroy_ = true;
142 }
143 }
144
145 // Overridden from ViewDestroyer:
146 View* GetDestroyedView() override {
147 return did_destroy_ ? view_to_destroy_ : nullptr;
148 }
149
150 private:
151 FocusController* focus_controller_;
152 View* view_to_destroy_;
153 bool did_destroy_;
154
155 DISALLOW_COPY_AND_ASSIGN(DestroyOnLoseActivationFocusNotificationObserver);
156 };
157
69 class ScopedFocusNotificationObserver : public FocusNotificationObserver { 158 class ScopedFocusNotificationObserver : public FocusNotificationObserver {
70 public: 159 public:
71 ScopedFocusNotificationObserver(FocusController* focus_controller) 160 ScopedFocusNotificationObserver(FocusController* focus_controller)
72 : focus_controller_(focus_controller) { 161 : focus_controller_(focus_controller) {
73 focus_controller_->AddObserver(this); 162 focus_controller_->AddObserver(this);
74 } 163 }
75 ~ScopedFocusNotificationObserver() override { 164 ~ScopedFocusNotificationObserver() override {
76 focus_controller_->RemoveObserver(this); 165 focus_controller_->RemoveObserver(this);
77 } 166 }
78 167
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 263
175 // BasicFocusRules subclass that allows basic overrides of focus/activation to 264 // BasicFocusRules subclass that allows basic overrides of focus/activation to
176 // be tested. This is intended more as a test that the override system works at 265 // be tested. This is intended more as a test that the override system works at
177 // all, rather than as an exhaustive set of use cases, those should be covered 266 // all, rather than as an exhaustive set of use cases, those should be covered
178 // in tests for those FocusRules implementations. 267 // in tests for those FocusRules implementations.
179 class TestFocusRules : public BasicFocusRules { 268 class TestFocusRules : public BasicFocusRules {
180 public: 269 public:
181 TestFocusRules(View* root) 270 TestFocusRules(View* root)
182 : BasicFocusRules(root), focus_restriction_(NULL) {} 271 : BasicFocusRules(root), focus_restriction_(NULL) {}
183 272
184 // Restricts focus and activation to this window and its child hierarchy. 273 // Restricts focus and activation to this view and its child hierarchy.
185 void set_focus_restriction(View* focus_restriction) { 274 void set_focus_restriction(View* focus_restriction) {
186 focus_restriction_ = focus_restriction; 275 focus_restriction_ = focus_restriction;
187 } 276 }
188 277
189 // Overridden from BasicFocusRules: 278 // Overridden from BasicFocusRules:
190 bool SupportsChildActivation(View* view) const override { 279 bool SupportsChildActivation(View* view) const override {
191 // In FocusControllerTests, only the Root has activatable children. 280 // In FocusControllerTests, only the Root has activatable children.
192 return view->GetRoot() == view; 281 return view->GetRoot() == view;
193 } 282 }
194 bool CanActivateView(View* view) const override { 283 bool CanActivateView(View* view) const override {
(...skipping 29 matching lines...) Expand all
224 313
225 View* focus_restriction_; 314 View* focus_restriction_;
226 315
227 DISALLOW_COPY_AND_ASSIGN(TestFocusRules); 316 DISALLOW_COPY_AND_ASSIGN(TestFocusRules);
228 }; 317 };
229 318
230 // Common infrastructure shared by all FocusController test types. 319 // Common infrastructure shared by all FocusController test types.
231 class FocusControllerTestBase : public testing::Test { 320 class FocusControllerTestBase : public testing::Test {
232 protected: 321 protected:
233 // Hierarchy used by all tests: 322 // Hierarchy used by all tests:
234 // root_window 323 // root_view
235 // +-- w1 324 // +-- w1
236 // | +-- w11 325 // | +-- w11
237 // | +-- w12 326 // | +-- w12
238 // +-- w2 327 // +-- w2
239 // | +-- w21 328 // | +-- w21
240 // | +-- w211 329 // | +-- w211
241 // +-- w3 330 // +-- w3
242 FocusControllerTestBase() 331 FocusControllerTestBase()
243 : root_view_(0, gfx::Rect(0, 0, 800, 600)), 332 : root_view_(TestView::Build(0, gfx::Rect(0, 0, 800, 600))),
244 v1(1, gfx::Rect(0, 0, 50, 50), root_view()), 333 v1(TestView::Build(1, gfx::Rect(0, 0, 50, 50), root_view())),
245 v11(11, gfx::Rect(5, 5, 10, 10), &v1), 334 v11(TestView::Build(11, gfx::Rect(5, 5, 10, 10), v1)),
246 v12(12, gfx::Rect(15, 15, 10, 10), &v1), 335 v12(TestView::Build(12, gfx::Rect(15, 15, 10, 10), v1)),
247 v2(2, gfx::Rect(75, 75, 50, 50), root_view()), 336 v2(TestView::Build(2, gfx::Rect(75, 75, 50, 50), root_view())),
248 v21(21, gfx::Rect(5, 5, 10, 10), &v2), 337 v21(TestView::Build(21, gfx::Rect(5, 5, 10, 10), v2)),
249 v211(211, gfx::Rect(1, 1, 5, 5), &v21), 338 v211(TestView::Build(211, gfx::Rect(1, 1, 5, 5), v21)),
250 v3(3, gfx::Rect(125, 125, 50, 50), root_view()) {} 339 v3(TestView::Build(3, gfx::Rect(125, 125, 50, 50), root_view())) {}
251 340
252 // Overridden from testing::Test: 341 // Overridden from testing::Test:
253 void SetUp() override { 342 void SetUp() override {
254 testing::Test::SetUp(); 343 testing::Test::SetUp();
255 344
256 test_focus_rules_ = new TestFocusRules(root_view()); 345 test_focus_rules_ = new TestFocusRules(root_view());
257 focus_controller_.reset( 346 focus_controller_.reset(
258 new FocusController(scoped_ptr<FocusRules>(test_focus_rules_))); 347 new FocusController(scoped_ptr<FocusRules>(test_focus_rules_)));
259 348
260 ViewTarget* root_target = root_view_.target(); 349 ViewTarget* root_target = root_view_->target();
261 root_target->SetEventTargeter(scoped_ptr<ViewTargeter>(new ViewTargeter())); 350 root_target->SetEventTargeter(scoped_ptr<ViewTargeter>(new ViewTargeter()));
262 view_event_dispatcher_.reset(new ViewEventDispatcher()); 351 view_event_dispatcher_.reset(new ViewEventDispatcher());
263 view_event_dispatcher_->SetRootViewTarget(root_target); 352 view_event_dispatcher_->SetRootViewTarget(root_target);
264 353
265 GetRootViewTarget()->AddPreTargetHandler(focus_controller_.get()); 354 GetRootViewTarget()->AddPreTargetHandler(focus_controller_.get());
266 } 355 }
267 356
268 void TearDown() override { 357 void TearDown() override {
269 GetRootViewTarget()->RemovePreTargetHandler(focus_controller_.get()); 358 GetRootViewTarget()->RemovePreTargetHandler(focus_controller_.get());
270 view_event_dispatcher_.reset(); 359 view_event_dispatcher_.reset();
271 360
361 root_view_->Destroy();
362
272 test_focus_rules_ = nullptr; // Owned by FocusController. 363 test_focus_rules_ = nullptr; // Owned by FocusController.
273 focus_controller_.reset(); 364 focus_controller_.reset();
274 365
275 testing::Test::TearDown(); 366 testing::Test::TearDown();
276 } 367 }
277 368
278 void FocusView(View* view) { focus_controller_->FocusView(view); } 369 void FocusView(View* view) { focus_controller_->FocusView(view); }
279 View* GetFocusedView() { return focus_controller_->GetFocusedView(); } 370 View* GetFocusedView() { return focus_controller_->GetFocusedView(); }
280 int GetFocusedViewId() { 371 int GetFocusedViewId() {
281 View* focused_view = GetFocusedView(); 372 View* focused_view = GetFocusedView();
282 return focused_view ? focused_view->id() : -1; 373 return focused_view ? focused_view->id() : -1;
283 } 374 }
284 void ActivateView(View* view) { focus_controller_->ActivateView(view); } 375 void ActivateView(View* view) { focus_controller_->ActivateView(view); }
285 void DeactivateView(View* view) { focus_controller_->DeactivateView(view); } 376 void DeactivateView(View* view) { focus_controller_->DeactivateView(view); }
286 View* GetActiveView() { return focus_controller_->GetActiveView(); } 377 View* GetActiveView() { return focus_controller_->GetActiveView(); }
287 int GetActiveViewId() { 378 int GetActiveViewId() {
288 View* active_view = GetActiveView(); 379 View* active_view = GetActiveView();
289 return active_view ? active_view->id() : -1; 380 return active_view ? active_view->id() : -1;
290 } 381 }
291 382
292 View* GetViewById(int id) { return root_view_.GetChildById(id); } 383 View* GetViewById(int id) { return root_view_->GetChildById(id); }
293 384
294 void ClickLeftButton(View* view) { 385 void ClickLeftButton(View* view) {
295 // Get the center bounds of |target| in |root_view_| coordinate space. 386 // Get the center bounds of |target| in |root_view_| coordinate space.
296 gfx::Point center = 387 gfx::Point center =
297 gfx::Rect(view->bounds().To<gfx::Rect>().size()).CenterPoint(); 388 gfx::Rect(view->bounds().To<gfx::Rect>().size()).CenterPoint();
298 ViewTarget::ConvertPointToTarget(ViewTarget::TargetFromView(view), 389 ViewTarget::ConvertPointToTarget(ViewTarget::TargetFromView(view),
299 root_view_.target(), &center); 390 root_view_->target(), &center);
300 391
301 ui::MouseEvent button_down(ui::ET_MOUSE_PRESSED, center, center, 392 ui::MouseEvent button_down(ui::ET_MOUSE_PRESSED, center, center,
302 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_NONE); 393 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_NONE);
303 ui::EventDispatchDetails details = 394 ui::EventDispatchDetails details =
304 view_event_dispatcher_->OnEventFromSource(&button_down); 395 view_event_dispatcher_->OnEventFromSource(&button_down);
305 CHECK(!details.dispatcher_destroyed); 396 CHECK(!details.dispatcher_destroyed);
306 397
307 ui::MouseEvent button_up(ui::ET_MOUSE_RELEASED, center, center, 398 ui::MouseEvent button_up(ui::ET_MOUSE_RELEASED, center, center,
308 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_NONE); 399 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_NONE);
309 details = view_event_dispatcher_->OnEventFromSource(&button_up); 400 details = view_event_dispatcher_->OnEventFromSource(&button_up);
310 CHECK(!details.dispatcher_destroyed); 401 CHECK(!details.dispatcher_destroyed);
311 } 402 }
312 403
313 ViewTarget* GetRootViewTarget() { 404 ViewTarget* GetRootViewTarget() {
314 return ViewTarget::TargetFromView(root_view()); 405 return ViewTarget::TargetFromView(root_view());
315 } 406 }
316 407
317 View* root_view() { return &root_view_; } 408 View* root_view() { return root_view_; }
318 TestFocusRules* test_focus_rules() { return test_focus_rules_; } 409 TestFocusRules* test_focus_rules() { return test_focus_rules_; }
319 FocusController* focus_controller() { return focus_controller_.get(); } 410 FocusController* focus_controller() { return focus_controller_.get(); }
320 411
321 // Test functions. 412 // Test functions.
322 virtual void BasicFocus() = 0; 413 virtual void BasicFocus() = 0;
323 virtual void BasicActivation() = 0; 414 virtual void BasicActivation() = 0;
324 virtual void FocusEvents() = 0; 415 virtual void FocusEvents() = 0;
325 virtual void DuplicateFocusEvents() {} 416 virtual void DuplicateFocusEvents() {}
326 virtual void ActivationEvents() = 0; 417 virtual void ActivationEvents() = 0;
327 virtual void ReactivationEvents() {} 418 virtual void ReactivationEvents() {}
328 virtual void DuplicateActivationEvents() {} 419 virtual void DuplicateActivationEvents() {}
329 virtual void ShiftFocusWithinActiveView() {} 420 virtual void ShiftFocusWithinActiveView() {}
330 virtual void ShiftFocusToChildOfInactiveView() {} 421 virtual void ShiftFocusToChildOfInactiveView() {}
331 virtual void ShiftFocusToParentOfFocusedView() {} 422 virtual void ShiftFocusToParentOfFocusedView() {}
332 virtual void FocusRulesOverride() = 0; 423 virtual void FocusRulesOverride() = 0;
333 virtual void ActivationRulesOverride() = 0; 424 virtual void ActivationRulesOverride() = 0;
334 virtual void ShiftFocusOnActivation() {} 425 virtual void ShiftFocusOnActivation() {}
426 virtual void ShiftFocusOnActivationDueToHide() {}
427 virtual void NoShiftActiveOnActivation() {}
428 // TODO(erg): void NoFocusChangeOnClickOnCaptureWindow() once we have a
429 // system of capture.
430 // TODO(erg): Also, void ChangeFocusWhenNothingFocusedAndCaptured().
431 virtual void DontPassDestroyedView() {}
432 // TODO(erg): Also, void FocusedTextInputClient() once we build the IME.
335 433
336 private: 434 private:
337 TestView root_view_; 435 TestView* root_view_;
338 scoped_ptr<FocusController> focus_controller_; 436 scoped_ptr<FocusController> focus_controller_;
339 TestFocusRules* test_focus_rules_; 437 TestFocusRules* test_focus_rules_;
340 // TODO(erg): The aura version of this class also keeps track of WMState. Do 438 // TODO(erg): The aura version of this class also keeps track of WMState. Do
341 // we need something analogous here? 439 // we need something analogous here?
342 440
343 scoped_ptr<ViewEventDispatcher> view_event_dispatcher_; 441 scoped_ptr<ViewEventDispatcher> view_event_dispatcher_;
344 442
345 TestView v1; 443 TestView* v1;
346 TestView v11; 444 TestView* v11;
347 TestView v12; 445 TestView* v12;
348 TestView v2; 446 TestView* v2;
349 TestView v21; 447 TestView* v21;
350 TestView v211; 448 TestView* v211;
351 TestView v3; 449 TestView* v3;
352 450
353 DISALLOW_COPY_AND_ASSIGN(FocusControllerTestBase); 451 DISALLOW_COPY_AND_ASSIGN(FocusControllerTestBase);
354 }; 452 };
355 453
356 // Test base for tests where focus is directly set to a target window. 454 // Test base for tests where focus is directly set to a target view.
357 class FocusControllerDirectTestBase : public FocusControllerTestBase { 455 class FocusControllerDirectTestBase : public FocusControllerTestBase {
358 protected: 456 protected:
359 FocusControllerDirectTestBase() {} 457 FocusControllerDirectTestBase() {}
360 458
361 // Different test types shift focus in different ways. 459 // Different test types shift focus in different ways.
362 virtual void FocusViewDirect(View* view) = 0; 460 virtual void FocusViewDirect(View* view) = 0;
363 virtual void ActivateViewDirect(View* view) = 0; 461 virtual void ActivateViewDirect(View* view) = 0;
364 virtual void DeactivateViewDirect(View* view) = 0; 462 virtual void DeactivateViewDirect(View* view) = 0;
365 463
366 // Input events do not change focus if the window can not be focused. 464 // Input events do not change focus if the view can not be focused.
367 virtual bool IsInputEvent() = 0; 465 virtual bool IsInputEvent() = 0;
368 466
369 void FocusViewById(int id) { 467 void FocusViewById(int id) {
370 View* view = root_view()->GetChildById(id); 468 View* view = root_view()->GetChildById(id);
371 DCHECK(view); 469 DCHECK(view);
372 FocusViewDirect(view); 470 FocusViewDirect(view);
373 } 471 }
374 void ActivateViewById(int id) { 472 void ActivateViewById(int id) {
375 View* view = root_view()->GetChildById(id); 473 View* view = root_view()->GetChildById(id);
376 DCHECK(view); 474 DCHECK(view);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 root_observer.ExpectCounts(1, 1); 511 root_observer.ExpectCounts(1, 1);
414 observer1.ExpectCounts(1, 1); 512 observer1.ExpectCounts(1, 1);
415 observer2.ExpectCounts(0, 0); 513 observer2.ExpectCounts(0, 0);
416 514
417 FocusViewById(2); 515 FocusViewById(2);
418 root_observer.ExpectCounts(2, 2); 516 root_observer.ExpectCounts(2, 2);
419 observer1.ExpectCounts(2, 2); 517 observer1.ExpectCounts(2, 2);
420 observer2.ExpectCounts(1, 1); 518 observer2.ExpectCounts(1, 1);
421 } 519 }
422 void DuplicateFocusEvents() override { 520 void DuplicateFocusEvents() override {
423 // Focusing an existing focused window should not resend focus events. 521 // Focusing an existing focused view should not resend focus events.
424 ScopedFocusNotificationObserver root_observer(focus_controller()); 522 ScopedFocusNotificationObserver root_observer(focus_controller());
425 ScopedFilteringFocusNotificationObserver observer1(focus_controller(), 523 ScopedFilteringFocusNotificationObserver observer1(focus_controller(),
426 GetViewById(1)); 524 GetViewById(1));
427 525
428 root_observer.ExpectCounts(0, 0); 526 root_observer.ExpectCounts(0, 0);
429 observer1.ExpectCounts(0, 0); 527 observer1.ExpectCounts(0, 0);
430 528
431 FocusViewById(1); 529 FocusViewById(1);
432 root_observer.ExpectCounts(1, 1); 530 root_observer.ExpectCounts(1, 1);
433 observer1.ExpectCounts(1, 1); 531 observer1.ExpectCounts(1, 1);
(...skipping 23 matching lines...) Expand all
457 void ReactivationEvents() override { 555 void ReactivationEvents() override {
458 ActivateViewById(1); 556 ActivateViewById(1);
459 ScopedFocusNotificationObserver root_observer(focus_controller()); 557 ScopedFocusNotificationObserver root_observer(focus_controller());
460 EXPECT_EQ(0, root_observer.reactivation_count()); 558 EXPECT_EQ(0, root_observer.reactivation_count());
461 GetViewById(2)->SetVisible(false); 559 GetViewById(2)->SetVisible(false);
462 // When we attempt to activate "2", which cannot be activated because it 560 // When we attempt to activate "2", which cannot be activated because it
463 // is not visible, "1" will be reactivated. 561 // is not visible, "1" will be reactivated.
464 ActivateViewById(2); 562 ActivateViewById(2);
465 EXPECT_EQ(1, root_observer.reactivation_count()); 563 EXPECT_EQ(1, root_observer.reactivation_count());
466 EXPECT_EQ(GetViewById(2), 564 EXPECT_EQ(GetViewById(2),
467 root_observer.reactivation_requested_window()); 565 root_observer.reactivation_requested_view());
468 EXPECT_EQ(GetViewById(1), 566 EXPECT_EQ(GetViewById(1),
469 root_observer.reactivation_actual_window()); 567 root_observer.reactivation_actual_view());
470 } 568 }
471 void DuplicateActivationEvents() override { 569 void DuplicateActivationEvents() override {
472 // Activating an existing active window should not resend activation events. 570 // Activating an existing active view should not resend activation events.
473 ActivateViewById(1); 571 ActivateViewById(1);
474 572
475 ScopedFocusNotificationObserver root_observer(focus_controller()); 573 ScopedFocusNotificationObserver root_observer(focus_controller());
476 ScopedFilteringFocusNotificationObserver observer1(focus_controller(), 574 ScopedFilteringFocusNotificationObserver observer1(focus_controller(),
477 GetViewById(1)); 575 GetViewById(1));
478 ScopedFilteringFocusNotificationObserver observer2(focus_controller(), 576 ScopedFilteringFocusNotificationObserver observer2(focus_controller(),
479 GetViewById(2)); 577 GetViewById(2));
480 578
481 root_observer.ExpectCounts(0, 0); 579 root_observer.ExpectCounts(0, 0);
482 observer1.ExpectCounts(0, 0); 580 observer1.ExpectCounts(0, 0);
(...skipping 25 matching lines...) Expand all
508 FocusViewById(11); 606 FocusViewById(11);
509 EXPECT_EQ(1, GetActiveViewId()); 607 EXPECT_EQ(1, GetActiveViewId());
510 EXPECT_EQ(11, GetFocusedViewId()); 608 EXPECT_EQ(11, GetFocusedViewId());
511 } 609 }
512 void ShiftFocusToParentOfFocusedView() override { 610 void ShiftFocusToParentOfFocusedView() override {
513 ActivateViewById(1); 611 ActivateViewById(1);
514 EXPECT_EQ(1, GetFocusedViewId()); 612 EXPECT_EQ(1, GetFocusedViewId());
515 FocusViewById(11); 613 FocusViewById(11);
516 EXPECT_EQ(11, GetFocusedViewId()); 614 EXPECT_EQ(11, GetFocusedViewId());
517 FocusViewById(1); 615 FocusViewById(1);
518 // Focus should _not_ shift to the parent of the already-focused window. 616 // Focus should _not_ shift to the parent of the already-focused view.
519 EXPECT_EQ(11, GetFocusedViewId()); 617 EXPECT_EQ(11, GetFocusedViewId());
520 } 618 }
521 void FocusRulesOverride() override { 619 void FocusRulesOverride() override {
522 EXPECT_EQ(NULL, GetFocusedView()); 620 EXPECT_EQ(NULL, GetFocusedView());
523 FocusViewById(11); 621 FocusViewById(11);
524 EXPECT_EQ(11, GetFocusedViewId()); 622 EXPECT_EQ(11, GetFocusedViewId());
525 623
526 test_focus_rules()->set_focus_restriction(GetViewById(211)); 624 test_focus_rules()->set_focus_restriction(GetViewById(211));
527 FocusViewById(12); 625 FocusViewById(12);
528 // Input events leave focus unchanged; direct API calls will change focus 626 // Input events leave focus unchanged; direct API calls will change focus
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 ActivateViewById(1); 685 ActivateViewById(1);
588 EXPECT_EQ(1, GetFocusedViewId()); 686 EXPECT_EQ(1, GetFocusedViewId());
589 687
590 focus_controller()->RemoveObserver(observer.get()); 688 focus_controller()->RemoveObserver(observer.get());
591 689
592 ActivateViewById(2); 690 ActivateViewById(2);
593 EXPECT_EQ(2, GetFocusedViewId()); 691 EXPECT_EQ(2, GetFocusedViewId());
594 ActivateViewById(1); 692 ActivateViewById(1);
595 EXPECT_EQ(1, GetFocusedViewId()); 693 EXPECT_EQ(1, GetFocusedViewId());
596 } 694 }
695 void ShiftFocusOnActivationDueToHide() override {
696 // Similar to ShiftFocusOnActivation except the activation change is
697 // triggered by hiding the active view.
698 ActivateViewById(1);
699 EXPECT_EQ(1, GetFocusedViewId());
700
701 // Removes view 3 as candidate for next activatable view.
702 root_view()->GetChildById(3)->SetVisible(false);
703 EXPECT_EQ(1, GetFocusedViewId());
704
705 View* target = root_view()->GetChildById(2);
706
707 scoped_ptr<FocusShiftingActivationObserver> observer(
708 new FocusShiftingActivationObserver(focus_controller(), target));
709 observer->set_shift_focus_to(target->GetChildById(21));
710 focus_controller()->AddObserver(observer.get());
711
712 // Hide the active view.
713 root_view()->GetChildById(1)->SetVisible(false);
714
715 EXPECT_EQ(21, GetFocusedViewId());
716
717 focus_controller()->RemoveObserver(observer.get());
718 }
719 void NoShiftActiveOnActivation() override {
720 // When a view is activated, we need to prevent any change to activation
721 // from being made in response to an activation change notification.
722 }
723
724 // TODO(erg): Port the capture tests here, once we have a capture mechanism.
725
726 // Verifies if a view that loses activation or focus is destroyed during
727 // observer notification we don't pass the destroyed view to other observers.
728 void DontPassDestroyedView() override {
729 FocusViewById(1);
730
731 EXPECT_EQ(1, GetActiveViewId());
732 EXPECT_EQ(1, GetFocusedViewId());
733
734 {
735 View* to_destroy = root_view()->GetChildById(1);
736 DestroyOnLoseActivationFocusNotificationObserver observer1(
737 focus_controller(), to_destroy);
738 RecordingFocusNotificationObserver observer2(focus_controller(),
739 &observer1);
740
741 FocusViewById(2);
742
743 EXPECT_EQ(2, GetActiveViewId());
744 EXPECT_EQ(2, GetFocusedViewId());
745
746 EXPECT_EQ(to_destroy, observer1.GetDestroyedView());
747 EXPECT_FALSE(observer2.was_notified_with_destroyed_view());
748 }
749
750 {
751 View* to_destroy = root_view()->GetChildById(2);
752 DestroyOnLoseActivationFocusNotificationObserver observer1(
753 focus_controller(), to_destroy);
754 RecordingFocusNotificationObserver observer2(focus_controller(),
755 &observer1);
756
757 FocusViewById(3);
758
759 EXPECT_EQ(3, GetActiveViewId());
760 EXPECT_EQ(3, GetFocusedViewId());
761
762 EXPECT_EQ(to_destroy, observer1.GetDestroyedView());
763 EXPECT_FALSE(observer2.was_notified_with_destroyed_view());
764 }
765 }
597 766
598 767
599 // TODO(erg): There are a whole bunch other tests here. Port them. 768 // TODO(erg): There are a whole bunch other tests here. Port them.
600 769
601 private: 770 private:
602 DISALLOW_COPY_AND_ASSIGN(FocusControllerDirectTestBase); 771 DISALLOW_COPY_AND_ASSIGN(FocusControllerDirectTestBase);
603 }; 772 };
604 773
605 // Focus and Activation changes via the FocusController API. 774 // Focus and Activation changes via the FocusController API.
606 class FocusControllerApiTest : public FocusControllerDirectTestBase { 775 class FocusControllerApiTest : public FocusControllerDirectTestBase {
607 public: 776 public:
608 FocusControllerApiTest() {} 777 FocusControllerApiTest() {}
609 778
610 private: 779 private:
611 // Overridden from FocusControllerTestBase: 780 // Overridden from FocusControllerTestBase:
612 void FocusViewDirect(View* view) override { FocusView(view); } 781 void FocusViewDirect(View* view) override { FocusView(view); }
613 void ActivateViewDirect(View* view) override { ActivateView(view); } 782 void ActivateViewDirect(View* view) override { ActivateView(view); }
614 void DeactivateViewDirect(View* view) override { DeactivateView(view); } 783 void DeactivateViewDirect(View* view) override { DeactivateView(view); }
615 bool IsInputEvent() override { return false; } 784 bool IsInputEvent() override { return false; }
616 785
617 DISALLOW_COPY_AND_ASSIGN(FocusControllerApiTest); 786 DISALLOW_COPY_AND_ASSIGN(FocusControllerApiTest);
618 }; 787 };
619 788
620 // Focus and Activation changes via input events. 789 // Focus and Activation changes via input events.
621 class FocusControllerMouseEventTest : public FocusControllerDirectTestBase { 790 class FocusControllerMouseEventTest : public FocusControllerDirectTestBase {
622 public: 791 public:
623 FocusControllerMouseEventTest() {} 792 FocusControllerMouseEventTest() {}
624 793
625 // Tests that a handled mouse event does not trigger a window activation. 794 // Tests that a handled mouse event does not trigger a view activation.
626 void IgnoreHandledEvent() { 795 void IgnoreHandledEvent() {
627 EXPECT_EQ(NULL, GetActiveView()); 796 EXPECT_EQ(NULL, GetActiveView());
628 View* v1 = root_view()->GetChildById(1); 797 View* v1 = root_view()->GetChildById(1);
629 SimpleEventHandler handler; 798 SimpleEventHandler handler;
630 GetRootViewTarget()->PrependPreTargetHandler(&handler); 799 GetRootViewTarget()->PrependPreTargetHandler(&handler);
631 ClickLeftButton(v1); 800 ClickLeftButton(v1);
632 EXPECT_EQ(NULL, GetActiveView()); 801 EXPECT_EQ(NULL, GetActiveView());
633 // TODO(erg): Add gesture testing when we get gestures working. 802 // TODO(erg): Add gesture testing when we get gestures working.
634 GetRootViewTarget()->RemovePreTargetHandler(&handler); 803 GetRootViewTarget()->RemovePreTargetHandler(&handler);
635 ClickLeftButton(v1); 804 ClickLeftButton(v1);
636 EXPECT_EQ(1, GetActiveViewId()); 805 EXPECT_EQ(1, GetActiveViewId());
637 } 806 }
638 807
639 private: 808 private:
640 // Overridden from FocusControllerTestBase: 809 // Overridden from FocusControllerTestBase:
641 void FocusViewDirect(View* view) override { ClickLeftButton(view); } 810 void FocusViewDirect(View* view) override { ClickLeftButton(view); }
642 void ActivateViewDirect(View* view) override { ClickLeftButton(view); } 811 void ActivateViewDirect(View* view) override { ClickLeftButton(view); }
643 void DeactivateViewDirect(View* view) override { 812 void DeactivateViewDirect(View* view) override {
644 View* next_activatable = test_focus_rules()->GetNextActivatableView(view); 813 View* next_activatable = test_focus_rules()->GetNextActivatableView(view);
645 ClickLeftButton(next_activatable); 814 ClickLeftButton(next_activatable);
646 } 815 }
647 bool IsInputEvent() override { return true; } 816 bool IsInputEvent() override { return true; }
648 817
649 DISALLOW_COPY_AND_ASSIGN(FocusControllerMouseEventTest); 818 DISALLOW_COPY_AND_ASSIGN(FocusControllerMouseEventTest);
650 }; 819 };
651 820
821 // TODO(erg): Add a FocusControllerGestureEventTest once we have working
822 // gesture forwarding and handling.
823
824 // Test base for tests where focus is implicitly set to a window as the result
825 // of a disposition change to the focused window or the hierarchy that contains
826 // it.
827 class FocusControllerImplicitTestBase : public FocusControllerTestBase {
828 protected:
829 explicit FocusControllerImplicitTestBase(bool parent) : parent_(parent) {}
830
831 View* GetDispositionView(View* view) {
832 return parent_ ? view->parent() : view;
833 }
834
835 // Change the disposition of |view| in such a way as it will lose focus.
836 virtual void ChangeViewDisposition(View* view) = 0;
837
838 // Allow each disposition change test to add additional post-disposition
839 // change expectations.
840 virtual void PostDispostionChangeExpectations() {}
841
842 // Overridden from FocusControllerTestBase:
843 void BasicFocus() override {
844 EXPECT_EQ(NULL, GetFocusedView());
845
846 View* w211 = root_view()->GetChildById(211);
847 FocusView(w211);
848 EXPECT_EQ(211, GetFocusedViewId());
849
850 ChangeViewDisposition(w211);
851 // BasicFocusRules passes focus to the parent.
852 EXPECT_EQ(parent_ ? 2 : 21, GetFocusedViewId());
853 }
854
855 void BasicActivation() override {
856 DCHECK(!parent_) << "Activation tests don't support parent changes.";
857
858 EXPECT_EQ(NULL, GetActiveView());
859
860 View* w2 = root_view()->GetChildById(2);
861 ActivateView(w2);
862 EXPECT_EQ(2, GetActiveViewId());
863
864 ChangeViewDisposition(w2);
865 EXPECT_EQ(3, GetActiveViewId());
866 PostDispostionChangeExpectations();
867 }
868
869 void FocusEvents() override {
870 View* w211 = root_view()->GetChildById(211);
871 FocusView(w211);
872
873 ScopedFocusNotificationObserver root_observer(focus_controller());
874 ScopedFilteringFocusNotificationObserver observer211(focus_controller(),
875 GetViewById(211));
876 root_observer.ExpectCounts(0, 0);
877 observer211.ExpectCounts(0, 0);
878
879 ChangeViewDisposition(w211);
880 root_observer.ExpectCounts(0, 1);
881 observer211.ExpectCounts(0, 1);
882 }
883
884 void ActivationEvents() override {
885 DCHECK(!parent_) << "Activation tests don't support parent changes.";
886
887 View* w2 = root_view()->GetChildById(2);
888 ActivateView(w2);
889
890 ScopedFocusNotificationObserver root_observer(focus_controller());
891 ScopedFilteringFocusNotificationObserver observer2(focus_controller(),
892 GetViewById(2));
893 ScopedFilteringFocusNotificationObserver observer3(focus_controller(),
894 GetViewById(3));
895 root_observer.ExpectCounts(0, 0);
896 observer2.ExpectCounts(0, 0);
897 observer3.ExpectCounts(0, 0);
898
899 ChangeViewDisposition(w2);
900 root_observer.ExpectCounts(1, 1);
901 observer2.ExpectCounts(1, 1);
902 observer3.ExpectCounts(1, 1);
903 }
904
905 void FocusRulesOverride() override {
906 EXPECT_EQ(NULL, GetFocusedView());
907 View* w211 = root_view()->GetChildById(211);
908 FocusView(w211);
909 EXPECT_EQ(211, GetFocusedViewId());
910
911 test_focus_rules()->set_focus_restriction(root_view()->GetChildById(11));
912 ChangeViewDisposition(w211);
913 // Normally, focus would shift to the parent (w21) but the override shifts
914 // it to 11.
915 EXPECT_EQ(11, GetFocusedViewId());
916
917 test_focus_rules()->set_focus_restriction(NULL);
918 }
919
920 void ActivationRulesOverride() override {
921 DCHECK(!parent_) << "Activation tests don't support parent changes.";
922
923 View* w1 = root_view()->GetChildById(1);
924 ActivateView(w1);
925
926 EXPECT_EQ(1, GetActiveViewId());
927 EXPECT_EQ(1, GetFocusedViewId());
928
929 View* w3 = root_view()->GetChildById(3);
930 test_focus_rules()->set_focus_restriction(w3);
931
932 // Normally, activation/focus would move to w2, but since we have a focus
933 // restriction, it should move to w3 instead.
934 ChangeViewDisposition(w1);
935 EXPECT_EQ(3, GetActiveViewId());
936 EXPECT_EQ(3, GetFocusedViewId());
937
938 test_focus_rules()->set_focus_restriction(NULL);
939 ActivateView(root_view()->GetChildById(2));
940 EXPECT_EQ(2, GetActiveViewId());
941 EXPECT_EQ(2, GetFocusedViewId());
942 }
943
944 private:
945 // When true, the disposition change occurs to the parent of the window
946 // instead of to the window. This verifies that changes occurring in the
947 // hierarchy that contains the window affect the window's focus.
948 bool parent_;
949
950 DISALLOW_COPY_AND_ASSIGN(FocusControllerImplicitTestBase);
951 };
952
953 // Focus and Activation changes in response to window visibility changes.
954 class FocusControllerHideTest : public FocusControllerImplicitTestBase {
955 public:
956 FocusControllerHideTest() : FocusControllerImplicitTestBase(false) {}
957
958 protected:
959 FocusControllerHideTest(bool parent)
960 : FocusControllerImplicitTestBase(parent) {}
961
962 // Overridden from FocusControllerImplicitTestBase:
963 void ChangeViewDisposition(View* view) override {
964 GetDispositionView(view)->SetVisible(false);
965 }
966
967 private:
968 DISALLOW_COPY_AND_ASSIGN(FocusControllerHideTest);
969 };
970
971 // TODO(erg): Add FocusControllerParentHideTest and the rest.
972
973 // TODO(erg): Destroy view tests?
974
652 #define FOCUS_CONTROLLER_TEST(TESTCLASS, TESTNAME) \ 975 #define FOCUS_CONTROLLER_TEST(TESTCLASS, TESTNAME) \
653 TEST_F(TESTCLASS, TESTNAME) { TESTNAME(); } 976 TEST_F(TESTCLASS, TESTNAME) { TESTNAME(); }
654 977
655 // Runs direct focus change tests (input events and API calls). 978 // Runs direct focus change tests (input events and API calls).
656 // 979 //
657 // TODO(erg): Enable gesture events in the future. 980 // TODO(erg): Enable gesture events in the future.
658 #define DIRECT_FOCUS_CHANGE_TESTS(TESTNAME) \ 981 #define DIRECT_FOCUS_CHANGE_TESTS(TESTNAME) \
659 FOCUS_CONTROLLER_TEST(FocusControllerApiTest, TESTNAME) \ 982 FOCUS_CONTROLLER_TEST(FocusControllerApiTest, TESTNAME) \
660 FOCUS_CONTROLLER_TEST(FocusControllerMouseEventTest, TESTNAME) 983 FOCUS_CONTROLLER_TEST(FocusControllerMouseEventTest, TESTNAME)
661 984
662 // TODO(erg): Once all the basic tests are implemented, go through this list 985 // Runs implicit focus change tests for disposition changes to target.
663 // and change the ones which are ALL_FOCUS_TESTS() to the correct macro. 986 #define IMPLICIT_FOCUS_CHANGE_TARGET_TESTS(TESTNAME) \
987 FOCUS_CONTROLLER_TEST(FocusControllerHideTest, TESTNAME)
988 // TODO(erg): Add the destruction and removal tests once we've made View track
989 // visibility/destruction of its parents/children.
664 990
665 DIRECT_FOCUS_CHANGE_TESTS(BasicFocus); 991 // TODO(erg): Add IMPLICIT_FOCUS_CHANGE_PARENT_TESTS
666 DIRECT_FOCUS_CHANGE_TESTS(BasicActivation); 992
667 DIRECT_FOCUS_CHANGE_TESTS(FocusEvents); 993 // Runs all implicit focus change tests (changes to the target and target's
994 // parent hierarchy)
995 #define IMPLICIT_FOCUS_CHANGE_TESTS(TESTNAME) \
996 IMPLICIT_FOCUS_CHANGE_TARGET_TESTS(TESTNAME)
997 // TODO(erg): Enable
998 // IMPLICIT_FOCUS_CHANGE_PARENT_TESTS(TESTNAME)
999
1000 // Runs all possible focus change tests.
1001 #define ALL_FOCUS_TESTS(TESTNAME) \
1002 DIRECT_FOCUS_CHANGE_TESTS(TESTNAME) \
1003 IMPLICIT_FOCUS_CHANGE_TESTS(TESTNAME)
1004
1005 // Runs focus change tests that apply only to the target. For example,
1006 // implicit activation changes caused by window disposition changes do not
1007 // occur when changes to the containing hierarchy happen.
1008 #define TARGET_FOCUS_TESTS(TESTNAME) \
1009 DIRECT_FOCUS_CHANGE_TESTS(TESTNAME) \
1010 IMPLICIT_FOCUS_CHANGE_TARGET_TESTS(TESTNAME)
1011
1012 // - Focuses a window, verifies that focus changed.
1013 ALL_FOCUS_TESTS(BasicFocus);
1014
1015 // - Activates a window, verifies that activation changed.
1016 TARGET_FOCUS_TESTS(BasicActivation);
1017
1018 // - Focuses a window, verifies that focus events were dispatched.
1019 ALL_FOCUS_TESTS(FocusEvents);
1020
1021 // - Focuses or activates a window multiple times, verifies that events are only
1022 // dispatched when focus/activation actually changes.
668 DIRECT_FOCUS_CHANGE_TESTS(DuplicateFocusEvents); 1023 DIRECT_FOCUS_CHANGE_TESTS(DuplicateFocusEvents);
669 DIRECT_FOCUS_CHANGE_TESTS(DuplicateActivationEvents); 1024 DIRECT_FOCUS_CHANGE_TESTS(DuplicateActivationEvents);
670 1025
671 DIRECT_FOCUS_CHANGE_TESTS(ActivationEvents); 1026 // - Activates a window, verifies that activation events were dispatched.
1027 TARGET_FOCUS_TESTS(ActivationEvents);
1028
1029 // - Attempts to active a hidden view, verifies that current view is
1030 // attempted to be reactivated and the appropriate event dispatched.
1031 FOCUS_CONTROLLER_TEST(FocusControllerApiTest, ReactivationEvents);
672 1032
673 // - Input events/API calls shift focus between focusable views within the 1033 // - Input events/API calls shift focus between focusable views within the
674 // active view. 1034 // active view.
675 DIRECT_FOCUS_CHANGE_TESTS(ShiftFocusWithinActiveView); 1035 DIRECT_FOCUS_CHANGE_TESTS(ShiftFocusWithinActiveView);
676 1036
677 // - Input events/API calls to a child view of an inactive view shifts 1037 // - Input events/API calls to a child view of an inactive view shifts
678 // activation to the activatable parent and focuses the child. 1038 // activation to the activatable parent and focuses the child.
679 DIRECT_FOCUS_CHANGE_TESTS(ShiftFocusToChildOfInactiveView); 1039 DIRECT_FOCUS_CHANGE_TESTS(ShiftFocusToChildOfInactiveView);
680 1040
681 // - Input events/API calls to focus the parent of the focused view do not 1041 // - Input events/API calls to focus the parent of the focused view do not
682 // shift focus away from the child. 1042 // shift focus away from the child.
683 DIRECT_FOCUS_CHANGE_TESTS(ShiftFocusToParentOfFocusedView); 1043 DIRECT_FOCUS_CHANGE_TESTS(ShiftFocusToParentOfFocusedView);
684 1044
685 // - Attempts to active a hidden window, verifies that current window is
686 // attempted to be reactivated and the appropriate event dispatched.
687 FOCUS_CONTROLLER_TEST(FocusControllerApiTest, ReactivationEvents);
688
689 // - Verifies that FocusRules determine what can be focused. 1045 // - Verifies that FocusRules determine what can be focused.
690 DIRECT_FOCUS_CHANGE_TESTS(FocusRulesOverride); 1046 ALL_FOCUS_TESTS(FocusRulesOverride);
691 1047
692 // - Verifies that FocusRules determine what can be activated. 1048 // - Verifies that FocusRules determine what can be activated.
693 DIRECT_FOCUS_CHANGE_TESTS(ActivationRulesOverride); 1049 TARGET_FOCUS_TESTS(ActivationRulesOverride);
694 1050
695 // - Verifies that attempts to change focus or activation from a focus or 1051 // - Verifies that attempts to change focus or activation from a focus or
696 // activation change observer are ignored. 1052 // activation change observer are ignored.
697 DIRECT_FOCUS_CHANGE_TESTS(ShiftFocusOnActivation); 1053 DIRECT_FOCUS_CHANGE_TESTS(ShiftFocusOnActivation);
1054 DIRECT_FOCUS_CHANGE_TESTS(ShiftFocusOnActivationDueToHide);
1055 DIRECT_FOCUS_CHANGE_TESTS(NoShiftActiveOnActivation);
698 1056
699 // TODO(erg): Also port IMPLICIT_FOCUS_CHANGE_TARGET_TESTS / ALL_FOCUS_TESTS 1057 // TODO(erg): Add the capture tests here.
700 // here, and replace the above direct testing list.
701 1058
702 // If a mouse event was handled, it should not activate a window. 1059 // See description above DontPassDestroyedView() for details.
1060 FOCUS_CONTROLLER_TEST(FocusControllerApiTest, DontPassDestroyedView);
1061
1062 // TODO(erg): Add the TextInputClient tests here.
1063
1064 // If a mouse event was handled, it should not activate a view.
703 FOCUS_CONTROLLER_TEST(FocusControllerMouseEventTest, IgnoreHandledEvent); 1065 FOCUS_CONTROLLER_TEST(FocusControllerMouseEventTest, IgnoreHandledEvent);
704 1066
705 } // namespace mojo 1067 } // namespace mojo
OLDNEW
« no previous file with comments | « services/window_manager/focus_controller.cc ('k') | services/window_manager/window_manager_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698