OLD | NEW |
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 "ui/wm/core/focus_controller.h" | 5 #include "ui/wm/core/focus_controller.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "ui/aura/client/aura_constants.h" | 9 #include "ui/aura/client/aura_constants.h" |
10 #include "ui/aura/client/default_capture_client.h" | 10 #include "ui/aura/client/default_capture_client.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 aura::Window* reactivation_requested_window() const { | 49 aura::Window* reactivation_requested_window() const { |
50 return reactivation_requested_window_; | 50 return reactivation_requested_window_; |
51 } | 51 } |
52 aura::Window* reactivation_actual_window() const { | 52 aura::Window* reactivation_actual_window() const { |
53 return reactivation_actual_window_; | 53 return reactivation_actual_window_; |
54 } | 54 } |
55 | 55 |
56 private: | 56 private: |
57 // Overridden from aura::client::ActivationChangeObserver: | 57 // Overridden from aura::client::ActivationChangeObserver: |
58 virtual void OnWindowActivated(aura::Window* gained_active, | 58 virtual void OnWindowActivated(aura::Window* gained_active, |
59 aura::Window* lost_active) OVERRIDE { | 59 aura::Window* lost_active) override { |
60 ++activation_changed_count_; | 60 ++activation_changed_count_; |
61 } | 61 } |
62 virtual void OnAttemptToReactivateWindow( | 62 virtual void OnAttemptToReactivateWindow( |
63 aura::Window* request_active, | 63 aura::Window* request_active, |
64 aura::Window* actual_active) OVERRIDE { | 64 aura::Window* actual_active) override { |
65 ++reactivation_count_; | 65 ++reactivation_count_; |
66 reactivation_requested_window_ = request_active; | 66 reactivation_requested_window_ = request_active; |
67 reactivation_actual_window_ = actual_active; | 67 reactivation_actual_window_ = actual_active; |
68 } | 68 } |
69 | 69 |
70 // Overridden from aura::client::FocusChangeObserver: | 70 // Overridden from aura::client::FocusChangeObserver: |
71 virtual void OnWindowFocused(aura::Window* gained_focus, | 71 virtual void OnWindowFocused(aura::Window* gained_focus, |
72 aura::Window* lost_focus) OVERRIDE { | 72 aura::Window* lost_focus) override { |
73 ++focus_changed_count_; | 73 ++focus_changed_count_; |
74 } | 74 } |
75 | 75 |
76 int activation_changed_count_; | 76 int activation_changed_count_; |
77 int focus_changed_count_; | 77 int focus_changed_count_; |
78 int reactivation_count_; | 78 int reactivation_count_; |
79 aura::Window* reactivation_requested_window_; | 79 aura::Window* reactivation_requested_window_; |
80 aura::Window* reactivation_actual_window_; | 80 aura::Window* reactivation_actual_window_; |
81 | 81 |
82 DISALLOW_COPY_AND_ASSIGN(FocusNotificationObserver); | 82 DISALLOW_COPY_AND_ASSIGN(FocusNotificationObserver); |
(...skipping 26 matching lines...) Expand all Loading... |
109 aura::client::GetActivationClient(root_)->RemoveObserver(this); | 109 aura::client::GetActivationClient(root_)->RemoveObserver(this); |
110 aura::client::GetFocusClient(root_)->RemoveObserver(this); | 110 aura::client::GetFocusClient(root_)->RemoveObserver(this); |
111 } | 111 } |
112 | 112 |
113 bool was_notified_with_deleted_window() const { | 113 bool was_notified_with_deleted_window() const { |
114 return was_notified_with_deleted_window_; | 114 return was_notified_with_deleted_window_; |
115 } | 115 } |
116 | 116 |
117 // Overridden from aura::client::ActivationChangeObserver: | 117 // Overridden from aura::client::ActivationChangeObserver: |
118 virtual void OnWindowActivated(aura::Window* gained_active, | 118 virtual void OnWindowActivated(aura::Window* gained_active, |
119 aura::Window* lost_active) OVERRIDE { | 119 aura::Window* lost_active) override { |
120 if (lost_active && lost_active == deleter_->GetDeletedWindow()) | 120 if (lost_active && lost_active == deleter_->GetDeletedWindow()) |
121 was_notified_with_deleted_window_ = true; | 121 was_notified_with_deleted_window_ = true; |
122 } | 122 } |
123 | 123 |
124 // Overridden from aura::client::FocusChangeObserver: | 124 // Overridden from aura::client::FocusChangeObserver: |
125 virtual void OnWindowFocused(aura::Window* gained_focus, | 125 virtual void OnWindowFocused(aura::Window* gained_focus, |
126 aura::Window* lost_focus) OVERRIDE { | 126 aura::Window* lost_focus) override { |
127 if (lost_focus && lost_focus == deleter_->GetDeletedWindow()) | 127 if (lost_focus && lost_focus == deleter_->GetDeletedWindow()) |
128 was_notified_with_deleted_window_ = true; | 128 was_notified_with_deleted_window_ = true; |
129 } | 129 } |
130 | 130 |
131 private: | 131 private: |
132 aura::Window* root_; | 132 aura::Window* root_; |
133 | 133 |
134 // Not owned. | 134 // Not owned. |
135 WindowDeleter* deleter_; | 135 WindowDeleter* deleter_; |
136 | 136 |
(...skipping 15 matching lines...) Expand all Loading... |
152 window_(window), | 152 window_(window), |
153 did_delete_(false) { | 153 did_delete_(false) { |
154 aura::client::GetActivationClient(root_)->AddObserver(this); | 154 aura::client::GetActivationClient(root_)->AddObserver(this); |
155 } | 155 } |
156 virtual ~DeleteOnLoseActivationChangeObserver() { | 156 virtual ~DeleteOnLoseActivationChangeObserver() { |
157 aura::client::GetActivationClient(root_)->RemoveObserver(this); | 157 aura::client::GetActivationClient(root_)->RemoveObserver(this); |
158 } | 158 } |
159 | 159 |
160 // Overridden from aura::client::ActivationChangeObserver: | 160 // Overridden from aura::client::ActivationChangeObserver: |
161 virtual void OnWindowActivated(aura::Window* gained_active, | 161 virtual void OnWindowActivated(aura::Window* gained_active, |
162 aura::Window* lost_active) OVERRIDE { | 162 aura::Window* lost_active) override { |
163 if (window_ && lost_active == window_) { | 163 if (window_ && lost_active == window_) { |
164 delete lost_active; | 164 delete lost_active; |
165 did_delete_ = true; | 165 did_delete_ = true; |
166 } | 166 } |
167 } | 167 } |
168 | 168 |
169 // Overridden from WindowDeleter: | 169 // Overridden from WindowDeleter: |
170 virtual aura::Window* GetDeletedWindow() OVERRIDE { | 170 virtual aura::Window* GetDeletedWindow() override { |
171 return did_delete_ ? window_ : NULL; | 171 return did_delete_ ? window_ : NULL; |
172 } | 172 } |
173 | 173 |
174 private: | 174 private: |
175 aura::Window* root_; | 175 aura::Window* root_; |
176 aura::Window* window_; | 176 aura::Window* window_; |
177 bool did_delete_; | 177 bool did_delete_; |
178 | 178 |
179 DISALLOW_COPY_AND_ASSIGN(DeleteOnLoseActivationChangeObserver); | 179 DISALLOW_COPY_AND_ASSIGN(DeleteOnLoseActivationChangeObserver); |
180 }; | 180 }; |
181 | 181 |
182 // FocusChangeObserver that deletes the window losing focus. | 182 // FocusChangeObserver that deletes the window losing focus. |
183 class DeleteOnLoseFocusChangeObserver | 183 class DeleteOnLoseFocusChangeObserver |
184 : public aura::client::FocusChangeObserver, | 184 : public aura::client::FocusChangeObserver, |
185 public WindowDeleter { | 185 public WindowDeleter { |
186 public: | 186 public: |
187 explicit DeleteOnLoseFocusChangeObserver(aura::Window* window) | 187 explicit DeleteOnLoseFocusChangeObserver(aura::Window* window) |
188 : root_(window->GetRootWindow()), | 188 : root_(window->GetRootWindow()), |
189 window_(window), | 189 window_(window), |
190 did_delete_(false) { | 190 did_delete_(false) { |
191 aura::client::GetFocusClient(root_)->AddObserver(this); | 191 aura::client::GetFocusClient(root_)->AddObserver(this); |
192 } | 192 } |
193 virtual ~DeleteOnLoseFocusChangeObserver() { | 193 virtual ~DeleteOnLoseFocusChangeObserver() { |
194 aura::client::GetFocusClient(root_)->RemoveObserver(this); | 194 aura::client::GetFocusClient(root_)->RemoveObserver(this); |
195 } | 195 } |
196 | 196 |
197 // Overridden from aura::client::FocusChangeObserver: | 197 // Overridden from aura::client::FocusChangeObserver: |
198 virtual void OnWindowFocused(aura::Window* gained_focus, | 198 virtual void OnWindowFocused(aura::Window* gained_focus, |
199 aura::Window* lost_focus) OVERRIDE { | 199 aura::Window* lost_focus) override { |
200 if (window_ && lost_focus == window_) { | 200 if (window_ && lost_focus == window_) { |
201 delete lost_focus; | 201 delete lost_focus; |
202 did_delete_ = true; | 202 did_delete_ = true; |
203 } | 203 } |
204 } | 204 } |
205 | 205 |
206 // Overridden from WindowDeleter: | 206 // Overridden from WindowDeleter: |
207 virtual aura::Window* GetDeletedWindow() OVERRIDE { | 207 virtual aura::Window* GetDeletedWindow() override { |
208 return did_delete_ ? window_ : NULL; | 208 return did_delete_ ? window_ : NULL; |
209 } | 209 } |
210 | 210 |
211 private: | 211 private: |
212 aura::Window* root_; | 212 aura::Window* root_; |
213 aura::Window* window_; | 213 aura::Window* window_; |
214 bool did_delete_; | 214 bool did_delete_; |
215 | 215 |
216 DISALLOW_COPY_AND_ASSIGN(DeleteOnLoseFocusChangeObserver); | 216 DISALLOW_COPY_AND_ASSIGN(DeleteOnLoseFocusChangeObserver); |
217 }; | 217 }; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 : public ScopedFocusNotificationObserver { | 260 : public ScopedFocusNotificationObserver { |
261 public: | 261 public: |
262 ScopedFocusedTextInputClientChanger(aura::Window* root_window, | 262 ScopedFocusedTextInputClientChanger(aura::Window* root_window, |
263 ui::TextInputClient* text_input_client) | 263 ui::TextInputClient* text_input_client) |
264 : ScopedFocusNotificationObserver(root_window), | 264 : ScopedFocusNotificationObserver(root_window), |
265 text_input_client_(text_input_client) {} | 265 text_input_client_(text_input_client) {} |
266 | 266 |
267 private: | 267 private: |
268 // Overridden from aura::client::FocusChangeObserver: | 268 // Overridden from aura::client::FocusChangeObserver: |
269 virtual void OnWindowFocused(aura::Window* gained_focus, | 269 virtual void OnWindowFocused(aura::Window* gained_focus, |
270 aura::Window* lost_focus) OVERRIDE { | 270 aura::Window* lost_focus) override { |
271 ui::TextInputFocusManager::GetInstance()->FocusTextInputClient( | 271 ui::TextInputFocusManager::GetInstance()->FocusTextInputClient( |
272 text_input_client_); | 272 text_input_client_); |
273 } | 273 } |
274 | 274 |
275 ui::TextInputClient* text_input_client_; | 275 ui::TextInputClient* text_input_client_; |
276 }; | 276 }; |
277 | 277 |
278 // Used to fake the handling of events in the pre-target phase. | 278 // Used to fake the handling of events in the pre-target phase. |
279 class SimpleEventHandler : public ui::EventHandler { | 279 class SimpleEventHandler : public ui::EventHandler { |
280 public: | 280 public: |
281 SimpleEventHandler() {} | 281 SimpleEventHandler() {} |
282 virtual ~SimpleEventHandler() {} | 282 virtual ~SimpleEventHandler() {} |
283 | 283 |
284 // Overridden from ui::EventHandler: | 284 // Overridden from ui::EventHandler: |
285 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { | 285 virtual void OnMouseEvent(ui::MouseEvent* event) override { |
286 event->SetHandled(); | 286 event->SetHandled(); |
287 } | 287 } |
288 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { | 288 virtual void OnGestureEvent(ui::GestureEvent* event) override { |
289 event->SetHandled(); | 289 event->SetHandled(); |
290 } | 290 } |
291 | 291 |
292 private: | 292 private: |
293 DISALLOW_COPY_AND_ASSIGN(SimpleEventHandler); | 293 DISALLOW_COPY_AND_ASSIGN(SimpleEventHandler); |
294 }; | 294 }; |
295 | 295 |
296 class FocusShiftingActivationObserver | 296 class FocusShiftingActivationObserver |
297 : public aura::client::ActivationChangeObserver { | 297 : public aura::client::ActivationChangeObserver { |
298 public: | 298 public: |
299 explicit FocusShiftingActivationObserver(aura::Window* activated_window) | 299 explicit FocusShiftingActivationObserver(aura::Window* activated_window) |
300 : activated_window_(activated_window), | 300 : activated_window_(activated_window), |
301 shift_focus_to_(NULL) {} | 301 shift_focus_to_(NULL) {} |
302 virtual ~FocusShiftingActivationObserver() {} | 302 virtual ~FocusShiftingActivationObserver() {} |
303 | 303 |
304 void set_shift_focus_to(aura::Window* shift_focus_to) { | 304 void set_shift_focus_to(aura::Window* shift_focus_to) { |
305 shift_focus_to_ = shift_focus_to; | 305 shift_focus_to_ = shift_focus_to; |
306 } | 306 } |
307 | 307 |
308 private: | 308 private: |
309 // Overridden from aura::client::ActivationChangeObserver: | 309 // Overridden from aura::client::ActivationChangeObserver: |
310 virtual void OnWindowActivated(aura::Window* gained_active, | 310 virtual void OnWindowActivated(aura::Window* gained_active, |
311 aura::Window* lost_active) OVERRIDE { | 311 aura::Window* lost_active) override { |
312 // Shift focus to a child. This should prevent the default focusing from | 312 // Shift focus to a child. This should prevent the default focusing from |
313 // occurring in FocusController::FocusWindow(). | 313 // occurring in FocusController::FocusWindow(). |
314 if (gained_active == activated_window_) { | 314 if (gained_active == activated_window_) { |
315 aura::client::FocusClient* client = | 315 aura::client::FocusClient* client = |
316 aura::client::GetFocusClient(gained_active); | 316 aura::client::GetFocusClient(gained_active); |
317 client->FocusWindow(shift_focus_to_); | 317 client->FocusWindow(shift_focus_to_); |
318 } | 318 } |
319 } | 319 } |
320 | 320 |
321 aura::Window* activated_window_; | 321 aura::Window* activated_window_; |
322 aura::Window* shift_focus_to_; | 322 aura::Window* shift_focus_to_; |
323 | 323 |
324 DISALLOW_COPY_AND_ASSIGN(FocusShiftingActivationObserver); | 324 DISALLOW_COPY_AND_ASSIGN(FocusShiftingActivationObserver); |
325 }; | 325 }; |
326 | 326 |
327 // BaseFocusRules subclass that allows basic overrides of focus/activation to | 327 // BaseFocusRules subclass that allows basic overrides of focus/activation to |
328 // be tested. This is intended more as a test that the override system works at | 328 // be tested. This is intended more as a test that the override system works at |
329 // all, rather than as an exhaustive set of use cases, those should be covered | 329 // all, rather than as an exhaustive set of use cases, those should be covered |
330 // in tests for those FocusRules implementations. | 330 // in tests for those FocusRules implementations. |
331 class TestFocusRules : public BaseFocusRules { | 331 class TestFocusRules : public BaseFocusRules { |
332 public: | 332 public: |
333 TestFocusRules() : focus_restriction_(NULL) {} | 333 TestFocusRules() : focus_restriction_(NULL) {} |
334 | 334 |
335 // Restricts focus and activation to this window and its child hierarchy. | 335 // Restricts focus and activation to this window and its child hierarchy. |
336 void set_focus_restriction(aura::Window* focus_restriction) { | 336 void set_focus_restriction(aura::Window* focus_restriction) { |
337 focus_restriction_ = focus_restriction; | 337 focus_restriction_ = focus_restriction; |
338 } | 338 } |
339 | 339 |
340 // Overridden from BaseFocusRules: | 340 // Overridden from BaseFocusRules: |
341 virtual bool SupportsChildActivation(aura::Window* window) const OVERRIDE { | 341 virtual bool SupportsChildActivation(aura::Window* window) const override { |
342 // In FocusControllerTests, only the RootWindow has activatable children. | 342 // In FocusControllerTests, only the RootWindow has activatable children. |
343 return window->GetRootWindow() == window; | 343 return window->GetRootWindow() == window; |
344 } | 344 } |
345 virtual bool CanActivateWindow(aura::Window* window) const OVERRIDE { | 345 virtual bool CanActivateWindow(aura::Window* window) const override { |
346 // Restricting focus to a non-activatable child window means the activatable | 346 // Restricting focus to a non-activatable child window means the activatable |
347 // parent outside the focus restriction is activatable. | 347 // parent outside the focus restriction is activatable. |
348 bool can_activate = | 348 bool can_activate = |
349 CanFocusOrActivate(window) || window->Contains(focus_restriction_); | 349 CanFocusOrActivate(window) || window->Contains(focus_restriction_); |
350 return can_activate ? BaseFocusRules::CanActivateWindow(window) : false; | 350 return can_activate ? BaseFocusRules::CanActivateWindow(window) : false; |
351 } | 351 } |
352 virtual bool CanFocusWindow(aura::Window* window) const OVERRIDE { | 352 virtual bool CanFocusWindow(aura::Window* window) const override { |
353 return CanFocusOrActivate(window) ? | 353 return CanFocusOrActivate(window) ? |
354 BaseFocusRules::CanFocusWindow(window) : false; | 354 BaseFocusRules::CanFocusWindow(window) : false; |
355 } | 355 } |
356 virtual aura::Window* GetActivatableWindow( | 356 virtual aura::Window* GetActivatableWindow( |
357 aura::Window* window) const OVERRIDE { | 357 aura::Window* window) const override { |
358 return BaseFocusRules::GetActivatableWindow( | 358 return BaseFocusRules::GetActivatableWindow( |
359 CanFocusOrActivate(window) ? window : focus_restriction_); | 359 CanFocusOrActivate(window) ? window : focus_restriction_); |
360 } | 360 } |
361 virtual aura::Window* GetFocusableWindow( | 361 virtual aura::Window* GetFocusableWindow( |
362 aura::Window* window) const OVERRIDE { | 362 aura::Window* window) const override { |
363 return BaseFocusRules::GetFocusableWindow( | 363 return BaseFocusRules::GetFocusableWindow( |
364 CanFocusOrActivate(window) ? window : focus_restriction_); | 364 CanFocusOrActivate(window) ? window : focus_restriction_); |
365 } | 365 } |
366 virtual aura::Window* GetNextActivatableWindow( | 366 virtual aura::Window* GetNextActivatableWindow( |
367 aura::Window* ignore) const OVERRIDE { | 367 aura::Window* ignore) const override { |
368 aura::Window* next_activatable = | 368 aura::Window* next_activatable = |
369 BaseFocusRules::GetNextActivatableWindow(ignore); | 369 BaseFocusRules::GetNextActivatableWindow(ignore); |
370 return CanFocusOrActivate(next_activatable) ? | 370 return CanFocusOrActivate(next_activatable) ? |
371 next_activatable : GetActivatableWindow(focus_restriction_); | 371 next_activatable : GetActivatableWindow(focus_restriction_); |
372 } | 372 } |
373 | 373 |
374 private: | 374 private: |
375 bool CanFocusOrActivate(aura::Window* window) const { | 375 bool CanFocusOrActivate(aura::Window* window) const { |
376 return !focus_restriction_ || focus_restriction_->Contains(window); | 376 return !focus_restriction_ || focus_restriction_->Contains(window); |
377 } | 377 } |
378 | 378 |
379 aura::Window* focus_restriction_; | 379 aura::Window* focus_restriction_; |
380 | 380 |
381 DISALLOW_COPY_AND_ASSIGN(TestFocusRules); | 381 DISALLOW_COPY_AND_ASSIGN(TestFocusRules); |
382 }; | 382 }; |
383 | 383 |
384 // Common infrastructure shared by all FocusController test types. | 384 // Common infrastructure shared by all FocusController test types. |
385 class FocusControllerTestBase : public aura::test::AuraTestBase { | 385 class FocusControllerTestBase : public aura::test::AuraTestBase { |
386 protected: | 386 protected: |
387 FocusControllerTestBase() {} | 387 FocusControllerTestBase() {} |
388 | 388 |
389 // Overridden from aura::test::AuraTestBase: | 389 // Overridden from aura::test::AuraTestBase: |
390 virtual void SetUp() OVERRIDE { | 390 virtual void SetUp() override { |
391 wm_state_.reset(new wm::WMState); | 391 wm_state_.reset(new wm::WMState); |
392 // FocusController registers itself as an Env observer so it can catch all | 392 // FocusController registers itself as an Env observer so it can catch all |
393 // window initializations, including the root_window()'s, so we create it | 393 // window initializations, including the root_window()'s, so we create it |
394 // before allowing the base setup. | 394 // before allowing the base setup. |
395 test_focus_rules_ = new TestFocusRules; | 395 test_focus_rules_ = new TestFocusRules; |
396 focus_controller_.reset(new FocusController(test_focus_rules_)); | 396 focus_controller_.reset(new FocusController(test_focus_rules_)); |
397 aura::test::AuraTestBase::SetUp(); | 397 aura::test::AuraTestBase::SetUp(); |
398 root_window()->AddPreTargetHandler(focus_controller_.get()); | 398 root_window()->AddPreTargetHandler(focus_controller_.get()); |
399 aura::client::SetFocusClient(root_window(), focus_controller_.get()); | 399 aura::client::SetFocusClient(root_window(), focus_controller_.get()); |
400 aura::client::SetActivationClient(root_window(), focus_controller_.get()); | 400 aura::client::SetActivationClient(root_window(), focus_controller_.get()); |
(...skipping 22 matching lines...) Expand all Loading... |
423 aura::Window* w21 = aura::test::CreateTestWindowWithDelegate( | 423 aura::Window* w21 = aura::test::CreateTestWindowWithDelegate( |
424 aura::test::TestWindowDelegate::CreateSelfDestroyingDelegate(), 21, | 424 aura::test::TestWindowDelegate::CreateSelfDestroyingDelegate(), 21, |
425 gfx::Rect(5, 5, 10, 10), w2); | 425 gfx::Rect(5, 5, 10, 10), w2); |
426 aura::test::CreateTestWindowWithDelegate( | 426 aura::test::CreateTestWindowWithDelegate( |
427 aura::test::TestWindowDelegate::CreateSelfDestroyingDelegate(), 211, | 427 aura::test::TestWindowDelegate::CreateSelfDestroyingDelegate(), 211, |
428 gfx::Rect(1, 1, 5, 5), w21); | 428 gfx::Rect(1, 1, 5, 5), w21); |
429 aura::test::CreateTestWindowWithDelegate( | 429 aura::test::CreateTestWindowWithDelegate( |
430 aura::test::TestWindowDelegate::CreateSelfDestroyingDelegate(), 3, | 430 aura::test::TestWindowDelegate::CreateSelfDestroyingDelegate(), 3, |
431 gfx::Rect(125, 125, 50, 50), root_window()); | 431 gfx::Rect(125, 125, 50, 50), root_window()); |
432 } | 432 } |
433 virtual void TearDown() OVERRIDE { | 433 virtual void TearDown() override { |
434 root_window()->RemovePreTargetHandler(focus_controller_.get()); | 434 root_window()->RemovePreTargetHandler(focus_controller_.get()); |
435 aura::test::AuraTestBase::TearDown(); | 435 aura::test::AuraTestBase::TearDown(); |
436 test_focus_rules_ = NULL; // Owned by FocusController. | 436 test_focus_rules_ = NULL; // Owned by FocusController. |
437 focus_controller_.reset(); | 437 focus_controller_.reset(); |
438 wm_state_.reset(); | 438 wm_state_.reset(); |
439 } | 439 } |
440 | 440 |
441 void FocusWindow(aura::Window* window) { | 441 void FocusWindow(aura::Window* window) { |
442 aura::client::GetFocusClient(root_window())->FocusWindow(window); | 442 aura::client::GetFocusClient(root_window())->FocusWindow(window); |
443 } | 443 } |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 DCHECK(window); | 511 DCHECK(window); |
512 FocusWindowDirect(window); | 512 FocusWindowDirect(window); |
513 } | 513 } |
514 void ActivateWindowById(int id) { | 514 void ActivateWindowById(int id) { |
515 aura::Window* window = root_window()->GetChildById(id); | 515 aura::Window* window = root_window()->GetChildById(id); |
516 DCHECK(window); | 516 DCHECK(window); |
517 ActivateWindowDirect(window); | 517 ActivateWindowDirect(window); |
518 } | 518 } |
519 | 519 |
520 // Overridden from FocusControllerTestBase: | 520 // Overridden from FocusControllerTestBase: |
521 virtual void BasicFocus() OVERRIDE { | 521 virtual void BasicFocus() override { |
522 EXPECT_EQ(NULL, GetFocusedWindow()); | 522 EXPECT_EQ(NULL, GetFocusedWindow()); |
523 FocusWindowById(1); | 523 FocusWindowById(1); |
524 EXPECT_EQ(1, GetFocusedWindowId()); | 524 EXPECT_EQ(1, GetFocusedWindowId()); |
525 FocusWindowById(2); | 525 FocusWindowById(2); |
526 EXPECT_EQ(2, GetFocusedWindowId()); | 526 EXPECT_EQ(2, GetFocusedWindowId()); |
527 } | 527 } |
528 virtual void BasicActivation() OVERRIDE { | 528 virtual void BasicActivation() override { |
529 EXPECT_EQ(NULL, GetActiveWindow()); | 529 EXPECT_EQ(NULL, GetActiveWindow()); |
530 ActivateWindowById(1); | 530 ActivateWindowById(1); |
531 EXPECT_EQ(1, GetActiveWindowId()); | 531 EXPECT_EQ(1, GetActiveWindowId()); |
532 ActivateWindowById(2); | 532 ActivateWindowById(2); |
533 EXPECT_EQ(2, GetActiveWindowId()); | 533 EXPECT_EQ(2, GetActiveWindowId()); |
534 // Verify that attempting to deactivate NULL does not crash and does not | 534 // Verify that attempting to deactivate NULL does not crash and does not |
535 // change activation. | 535 // change activation. |
536 DeactivateWindow(NULL); | 536 DeactivateWindow(NULL); |
537 EXPECT_EQ(2, GetActiveWindowId()); | 537 EXPECT_EQ(2, GetActiveWindowId()); |
538 DeactivateWindow(GetActiveWindow()); | 538 DeactivateWindow(GetActiveWindow()); |
539 EXPECT_EQ(1, GetActiveWindowId()); | 539 EXPECT_EQ(1, GetActiveWindowId()); |
540 } | 540 } |
541 virtual void FocusEvents() OVERRIDE { | 541 virtual void FocusEvents() override { |
542 ScopedFocusNotificationObserver root_observer(root_window()); | 542 ScopedFocusNotificationObserver root_observer(root_window()); |
543 ScopedTargetFocusNotificationObserver observer1(root_window(), 1); | 543 ScopedTargetFocusNotificationObserver observer1(root_window(), 1); |
544 ScopedTargetFocusNotificationObserver observer2(root_window(), 2); | 544 ScopedTargetFocusNotificationObserver observer2(root_window(), 2); |
545 | 545 |
546 root_observer.ExpectCounts(0, 0); | 546 root_observer.ExpectCounts(0, 0); |
547 observer1.ExpectCounts(0, 0); | 547 observer1.ExpectCounts(0, 0); |
548 observer2.ExpectCounts(0, 0); | 548 observer2.ExpectCounts(0, 0); |
549 | 549 |
550 FocusWindowById(1); | 550 FocusWindowById(1); |
551 root_observer.ExpectCounts(1, 1); | 551 root_observer.ExpectCounts(1, 1); |
552 observer1.ExpectCounts(1, 1); | 552 observer1.ExpectCounts(1, 1); |
553 observer2.ExpectCounts(0, 0); | 553 observer2.ExpectCounts(0, 0); |
554 | 554 |
555 FocusWindowById(2); | 555 FocusWindowById(2); |
556 root_observer.ExpectCounts(2, 2); | 556 root_observer.ExpectCounts(2, 2); |
557 observer1.ExpectCounts(2, 2); | 557 observer1.ExpectCounts(2, 2); |
558 observer2.ExpectCounts(1, 1); | 558 observer2.ExpectCounts(1, 1); |
559 } | 559 } |
560 virtual void DuplicateFocusEvents() OVERRIDE { | 560 virtual void DuplicateFocusEvents() override { |
561 // Focusing an existing focused window should not resend focus events. | 561 // Focusing an existing focused window should not resend focus events. |
562 ScopedFocusNotificationObserver root_observer(root_window()); | 562 ScopedFocusNotificationObserver root_observer(root_window()); |
563 ScopedTargetFocusNotificationObserver observer1(root_window(), 1); | 563 ScopedTargetFocusNotificationObserver observer1(root_window(), 1); |
564 | 564 |
565 root_observer.ExpectCounts(0, 0); | 565 root_observer.ExpectCounts(0, 0); |
566 observer1.ExpectCounts(0, 0); | 566 observer1.ExpectCounts(0, 0); |
567 | 567 |
568 FocusWindowById(1); | 568 FocusWindowById(1); |
569 root_observer.ExpectCounts(1, 1); | 569 root_observer.ExpectCounts(1, 1); |
570 observer1.ExpectCounts(1, 1); | 570 observer1.ExpectCounts(1, 1); |
571 | 571 |
572 FocusWindowById(1); | 572 FocusWindowById(1); |
573 root_observer.ExpectCounts(1, 1); | 573 root_observer.ExpectCounts(1, 1); |
574 observer1.ExpectCounts(1, 1); | 574 observer1.ExpectCounts(1, 1); |
575 } | 575 } |
576 virtual void ActivationEvents() OVERRIDE { | 576 virtual void ActivationEvents() override { |
577 ActivateWindowById(1); | 577 ActivateWindowById(1); |
578 | 578 |
579 ScopedFocusNotificationObserver root_observer(root_window()); | 579 ScopedFocusNotificationObserver root_observer(root_window()); |
580 ScopedTargetFocusNotificationObserver observer1(root_window(), 1); | 580 ScopedTargetFocusNotificationObserver observer1(root_window(), 1); |
581 ScopedTargetFocusNotificationObserver observer2(root_window(), 2); | 581 ScopedTargetFocusNotificationObserver observer2(root_window(), 2); |
582 | 582 |
583 root_observer.ExpectCounts(0, 0); | 583 root_observer.ExpectCounts(0, 0); |
584 observer1.ExpectCounts(0, 0); | 584 observer1.ExpectCounts(0, 0); |
585 observer2.ExpectCounts(0, 0); | 585 observer2.ExpectCounts(0, 0); |
586 | 586 |
587 ActivateWindowById(2); | 587 ActivateWindowById(2); |
588 root_observer.ExpectCounts(1, 1); | 588 root_observer.ExpectCounts(1, 1); |
589 observer1.ExpectCounts(1, 1); | 589 observer1.ExpectCounts(1, 1); |
590 observer2.ExpectCounts(1, 1); | 590 observer2.ExpectCounts(1, 1); |
591 } | 591 } |
592 virtual void ReactivationEvents() OVERRIDE { | 592 virtual void ReactivationEvents() override { |
593 ActivateWindowById(1); | 593 ActivateWindowById(1); |
594 ScopedFocusNotificationObserver root_observer(root_window()); | 594 ScopedFocusNotificationObserver root_observer(root_window()); |
595 EXPECT_EQ(0, root_observer.reactivation_count()); | 595 EXPECT_EQ(0, root_observer.reactivation_count()); |
596 root_window()->GetChildById(2)->Hide(); | 596 root_window()->GetChildById(2)->Hide(); |
597 // When we attempt to activate "2", which cannot be activated because it | 597 // When we attempt to activate "2", which cannot be activated because it |
598 // is not visible, "1" will be reactivated. | 598 // is not visible, "1" will be reactivated. |
599 ActivateWindowById(2); | 599 ActivateWindowById(2); |
600 EXPECT_EQ(1, root_observer.reactivation_count()); | 600 EXPECT_EQ(1, root_observer.reactivation_count()); |
601 EXPECT_EQ(root_window()->GetChildById(2), | 601 EXPECT_EQ(root_window()->GetChildById(2), |
602 root_observer.reactivation_requested_window()); | 602 root_observer.reactivation_requested_window()); |
603 EXPECT_EQ(root_window()->GetChildById(1), | 603 EXPECT_EQ(root_window()->GetChildById(1), |
604 root_observer.reactivation_actual_window()); | 604 root_observer.reactivation_actual_window()); |
605 } | 605 } |
606 virtual void DuplicateActivationEvents() OVERRIDE { | 606 virtual void DuplicateActivationEvents() override { |
607 // Activating an existing active window should not resend activation events. | 607 // Activating an existing active window should not resend activation events. |
608 ActivateWindowById(1); | 608 ActivateWindowById(1); |
609 | 609 |
610 ScopedFocusNotificationObserver root_observer(root_window()); | 610 ScopedFocusNotificationObserver root_observer(root_window()); |
611 ScopedTargetFocusNotificationObserver observer1(root_window(), 1); | 611 ScopedTargetFocusNotificationObserver observer1(root_window(), 1); |
612 ScopedTargetFocusNotificationObserver observer2(root_window(), 2); | 612 ScopedTargetFocusNotificationObserver observer2(root_window(), 2); |
613 | 613 |
614 root_observer.ExpectCounts(0, 0); | 614 root_observer.ExpectCounts(0, 0); |
615 observer1.ExpectCounts(0, 0); | 615 observer1.ExpectCounts(0, 0); |
616 observer2.ExpectCounts(0, 0); | 616 observer2.ExpectCounts(0, 0); |
617 | 617 |
618 ActivateWindowById(2); | 618 ActivateWindowById(2); |
619 root_observer.ExpectCounts(1, 1); | 619 root_observer.ExpectCounts(1, 1); |
620 observer1.ExpectCounts(1, 1); | 620 observer1.ExpectCounts(1, 1); |
621 observer2.ExpectCounts(1, 1); | 621 observer2.ExpectCounts(1, 1); |
622 | 622 |
623 ActivateWindowById(2); | 623 ActivateWindowById(2); |
624 root_observer.ExpectCounts(1, 1); | 624 root_observer.ExpectCounts(1, 1); |
625 observer1.ExpectCounts(1, 1); | 625 observer1.ExpectCounts(1, 1); |
626 observer2.ExpectCounts(1, 1); | 626 observer2.ExpectCounts(1, 1); |
627 } | 627 } |
628 virtual void ShiftFocusWithinActiveWindow() OVERRIDE { | 628 virtual void ShiftFocusWithinActiveWindow() override { |
629 ActivateWindowById(1); | 629 ActivateWindowById(1); |
630 EXPECT_EQ(1, GetActiveWindowId()); | 630 EXPECT_EQ(1, GetActiveWindowId()); |
631 EXPECT_EQ(1, GetFocusedWindowId()); | 631 EXPECT_EQ(1, GetFocusedWindowId()); |
632 FocusWindowById(11); | 632 FocusWindowById(11); |
633 EXPECT_EQ(11, GetFocusedWindowId()); | 633 EXPECT_EQ(11, GetFocusedWindowId()); |
634 FocusWindowById(12); | 634 FocusWindowById(12); |
635 EXPECT_EQ(12, GetFocusedWindowId()); | 635 EXPECT_EQ(12, GetFocusedWindowId()); |
636 } | 636 } |
637 virtual void ShiftFocusToChildOfInactiveWindow() OVERRIDE { | 637 virtual void ShiftFocusToChildOfInactiveWindow() override { |
638 ActivateWindowById(2); | 638 ActivateWindowById(2); |
639 EXPECT_EQ(2, GetActiveWindowId()); | 639 EXPECT_EQ(2, GetActiveWindowId()); |
640 EXPECT_EQ(2, GetFocusedWindowId()); | 640 EXPECT_EQ(2, GetFocusedWindowId()); |
641 FocusWindowById(11); | 641 FocusWindowById(11); |
642 EXPECT_EQ(1, GetActiveWindowId()); | 642 EXPECT_EQ(1, GetActiveWindowId()); |
643 EXPECT_EQ(11, GetFocusedWindowId()); | 643 EXPECT_EQ(11, GetFocusedWindowId()); |
644 } | 644 } |
645 virtual void ShiftFocusToParentOfFocusedWindow() OVERRIDE { | 645 virtual void ShiftFocusToParentOfFocusedWindow() override { |
646 ActivateWindowById(1); | 646 ActivateWindowById(1); |
647 EXPECT_EQ(1, GetFocusedWindowId()); | 647 EXPECT_EQ(1, GetFocusedWindowId()); |
648 FocusWindowById(11); | 648 FocusWindowById(11); |
649 EXPECT_EQ(11, GetFocusedWindowId()); | 649 EXPECT_EQ(11, GetFocusedWindowId()); |
650 FocusWindowById(1); | 650 FocusWindowById(1); |
651 // Focus should _not_ shift to the parent of the already-focused window. | 651 // Focus should _not_ shift to the parent of the already-focused window. |
652 EXPECT_EQ(11, GetFocusedWindowId()); | 652 EXPECT_EQ(11, GetFocusedWindowId()); |
653 } | 653 } |
654 virtual void FocusRulesOverride() OVERRIDE { | 654 virtual void FocusRulesOverride() override { |
655 EXPECT_EQ(NULL, GetFocusedWindow()); | 655 EXPECT_EQ(NULL, GetFocusedWindow()); |
656 FocusWindowById(11); | 656 FocusWindowById(11); |
657 EXPECT_EQ(11, GetFocusedWindowId()); | 657 EXPECT_EQ(11, GetFocusedWindowId()); |
658 | 658 |
659 test_focus_rules()->set_focus_restriction(root_window()->GetChildById(211)); | 659 test_focus_rules()->set_focus_restriction(root_window()->GetChildById(211)); |
660 FocusWindowById(12); | 660 FocusWindowById(12); |
661 // Input events leave focus unchanged; direct API calls will change focus | 661 // Input events leave focus unchanged; direct API calls will change focus |
662 // to the restricted window. | 662 // to the restricted window. |
663 int focused_window = IsInputEvent() ? 11 : 211; | 663 int focused_window = IsInputEvent() ? 11 : 211; |
664 EXPECT_EQ(focused_window, GetFocusedWindowId()); | 664 EXPECT_EQ(focused_window, GetFocusedWindowId()); |
665 | 665 |
666 test_focus_rules()->set_focus_restriction(NULL); | 666 test_focus_rules()->set_focus_restriction(NULL); |
667 FocusWindowById(12); | 667 FocusWindowById(12); |
668 EXPECT_EQ(12, GetFocusedWindowId()); | 668 EXPECT_EQ(12, GetFocusedWindowId()); |
669 } | 669 } |
670 virtual void ActivationRulesOverride() OVERRIDE { | 670 virtual void ActivationRulesOverride() override { |
671 ActivateWindowById(1); | 671 ActivateWindowById(1); |
672 EXPECT_EQ(1, GetActiveWindowId()); | 672 EXPECT_EQ(1, GetActiveWindowId()); |
673 EXPECT_EQ(1, GetFocusedWindowId()); | 673 EXPECT_EQ(1, GetFocusedWindowId()); |
674 | 674 |
675 aura::Window* w3 = root_window()->GetChildById(3); | 675 aura::Window* w3 = root_window()->GetChildById(3); |
676 test_focus_rules()->set_focus_restriction(w3); | 676 test_focus_rules()->set_focus_restriction(w3); |
677 | 677 |
678 ActivateWindowById(2); | 678 ActivateWindowById(2); |
679 // Input events leave activation unchanged; direct API calls will activate | 679 // Input events leave activation unchanged; direct API calls will activate |
680 // the restricted window. | 680 // the restricted window. |
681 int active_window = IsInputEvent() ? 1 : 3; | 681 int active_window = IsInputEvent() ? 1 : 3; |
682 EXPECT_EQ(active_window, GetActiveWindowId()); | 682 EXPECT_EQ(active_window, GetActiveWindowId()); |
683 EXPECT_EQ(active_window, GetFocusedWindowId()); | 683 EXPECT_EQ(active_window, GetFocusedWindowId()); |
684 | 684 |
685 test_focus_rules()->set_focus_restriction(NULL); | 685 test_focus_rules()->set_focus_restriction(NULL); |
686 ActivateWindowById(2); | 686 ActivateWindowById(2); |
687 EXPECT_EQ(2, GetActiveWindowId()); | 687 EXPECT_EQ(2, GetActiveWindowId()); |
688 EXPECT_EQ(2, GetFocusedWindowId()); | 688 EXPECT_EQ(2, GetFocusedWindowId()); |
689 } | 689 } |
690 virtual void ShiftFocusOnActivation() OVERRIDE { | 690 virtual void ShiftFocusOnActivation() override { |
691 // When a window is activated, by default that window is also focused. | 691 // When a window is activated, by default that window is also focused. |
692 // An ActivationChangeObserver may shift focus to another window within the | 692 // An ActivationChangeObserver may shift focus to another window within the |
693 // same activatable window. | 693 // same activatable window. |
694 ActivateWindowById(2); | 694 ActivateWindowById(2); |
695 EXPECT_EQ(2, GetFocusedWindowId()); | 695 EXPECT_EQ(2, GetFocusedWindowId()); |
696 ActivateWindowById(1); | 696 ActivateWindowById(1); |
697 EXPECT_EQ(1, GetFocusedWindowId()); | 697 EXPECT_EQ(1, GetFocusedWindowId()); |
698 | 698 |
699 ActivateWindowById(2); | 699 ActivateWindowById(2); |
700 | 700 |
(...skipping 21 matching lines...) Expand all Loading... |
722 ActivateWindowById(1); | 722 ActivateWindowById(1); |
723 EXPECT_EQ(1, GetFocusedWindowId()); | 723 EXPECT_EQ(1, GetFocusedWindowId()); |
724 | 724 |
725 client->RemoveObserver(observer.get()); | 725 client->RemoveObserver(observer.get()); |
726 | 726 |
727 ActivateWindowById(2); | 727 ActivateWindowById(2); |
728 EXPECT_EQ(2, GetFocusedWindowId()); | 728 EXPECT_EQ(2, GetFocusedWindowId()); |
729 ActivateWindowById(1); | 729 ActivateWindowById(1); |
730 EXPECT_EQ(1, GetFocusedWindowId()); | 730 EXPECT_EQ(1, GetFocusedWindowId()); |
731 } | 731 } |
732 virtual void ShiftFocusOnActivationDueToHide() OVERRIDE { | 732 virtual void ShiftFocusOnActivationDueToHide() override { |
733 // Similar to ShiftFocusOnActivation except the activation change is | 733 // Similar to ShiftFocusOnActivation except the activation change is |
734 // triggered by hiding the active window. | 734 // triggered by hiding the active window. |
735 ActivateWindowById(1); | 735 ActivateWindowById(1); |
736 EXPECT_EQ(1, GetFocusedWindowId()); | 736 EXPECT_EQ(1, GetFocusedWindowId()); |
737 | 737 |
738 // Removes window 3 as candidate for next activatable window. | 738 // Removes window 3 as candidate for next activatable window. |
739 root_window()->GetChildById(3)->Hide(); | 739 root_window()->GetChildById(3)->Hide(); |
740 EXPECT_EQ(1, GetFocusedWindowId()); | 740 EXPECT_EQ(1, GetFocusedWindowId()); |
741 | 741 |
742 aura::Window* target = root_window()->GetChildById(2); | 742 aura::Window* target = root_window()->GetChildById(2); |
743 aura::client::ActivationClient* client = | 743 aura::client::ActivationClient* client = |
744 aura::client::GetActivationClient(root_window()); | 744 aura::client::GetActivationClient(root_window()); |
745 | 745 |
746 scoped_ptr<FocusShiftingActivationObserver> observer( | 746 scoped_ptr<FocusShiftingActivationObserver> observer( |
747 new FocusShiftingActivationObserver(target)); | 747 new FocusShiftingActivationObserver(target)); |
748 observer->set_shift_focus_to(target->GetChildById(21)); | 748 observer->set_shift_focus_to(target->GetChildById(21)); |
749 client->AddObserver(observer.get()); | 749 client->AddObserver(observer.get()); |
750 | 750 |
751 // Hide the active window. | 751 // Hide the active window. |
752 root_window()->GetChildById(1)->Hide(); | 752 root_window()->GetChildById(1)->Hide(); |
753 | 753 |
754 EXPECT_EQ(21, GetFocusedWindowId()); | 754 EXPECT_EQ(21, GetFocusedWindowId()); |
755 | 755 |
756 client->RemoveObserver(observer.get()); | 756 client->RemoveObserver(observer.get()); |
757 } | 757 } |
758 virtual void NoShiftActiveOnActivation() OVERRIDE { | 758 virtual void NoShiftActiveOnActivation() override { |
759 // When a window is activated, we need to prevent any change to activation | 759 // When a window is activated, we need to prevent any change to activation |
760 // from being made in response to an activation change notification. | 760 // from being made in response to an activation change notification. |
761 } | 761 } |
762 | 762 |
763 virtual void NoFocusChangeOnClickOnCaptureWindow() OVERRIDE { | 763 virtual void NoFocusChangeOnClickOnCaptureWindow() override { |
764 scoped_ptr<aura::client::DefaultCaptureClient> capture_client( | 764 scoped_ptr<aura::client::DefaultCaptureClient> capture_client( |
765 new aura::client::DefaultCaptureClient(root_window())); | 765 new aura::client::DefaultCaptureClient(root_window())); |
766 // Clicking on a window which has capture should not cause a focus change | 766 // Clicking on a window which has capture should not cause a focus change |
767 // to the window. This test verifies whether that is indeed the case. | 767 // to the window. This test verifies whether that is indeed the case. |
768 ActivateWindowById(1); | 768 ActivateWindowById(1); |
769 | 769 |
770 EXPECT_EQ(1, GetActiveWindowId()); | 770 EXPECT_EQ(1, GetActiveWindowId()); |
771 EXPECT_EQ(1, GetFocusedWindowId()); | 771 EXPECT_EQ(1, GetFocusedWindowId()); |
772 | 772 |
773 aura::Window* w2 = root_window()->GetChildById(2); | 773 aura::Window* w2 = root_window()->GetChildById(2); |
774 aura::client::GetCaptureClient(root_window())->SetCapture(w2); | 774 aura::client::GetCaptureClient(root_window())->SetCapture(w2); |
775 ui::test::EventGenerator generator(root_window(), w2); | 775 ui::test::EventGenerator generator(root_window(), w2); |
776 generator.ClickLeftButton(); | 776 generator.ClickLeftButton(); |
777 | 777 |
778 EXPECT_EQ(1, GetActiveWindowId()); | 778 EXPECT_EQ(1, GetActiveWindowId()); |
779 EXPECT_EQ(1, GetFocusedWindowId()); | 779 EXPECT_EQ(1, GetFocusedWindowId()); |
780 aura::client::GetCaptureClient(root_window())->ReleaseCapture(w2); | 780 aura::client::GetCaptureClient(root_window())->ReleaseCapture(w2); |
781 } | 781 } |
782 | 782 |
783 // Verifies focus change is honored while capture held. | 783 // Verifies focus change is honored while capture held. |
784 virtual void ChangeFocusWhenNothingFocusedAndCaptured() OVERRIDE { | 784 virtual void ChangeFocusWhenNothingFocusedAndCaptured() override { |
785 scoped_ptr<aura::client::DefaultCaptureClient> capture_client( | 785 scoped_ptr<aura::client::DefaultCaptureClient> capture_client( |
786 new aura::client::DefaultCaptureClient(root_window())); | 786 new aura::client::DefaultCaptureClient(root_window())); |
787 aura::Window* w1 = root_window()->GetChildById(1); | 787 aura::Window* w1 = root_window()->GetChildById(1); |
788 aura::client::GetCaptureClient(root_window())->SetCapture(w1); | 788 aura::client::GetCaptureClient(root_window())->SetCapture(w1); |
789 | 789 |
790 EXPECT_EQ(-1, GetActiveWindowId()); | 790 EXPECT_EQ(-1, GetActiveWindowId()); |
791 EXPECT_EQ(-1, GetFocusedWindowId()); | 791 EXPECT_EQ(-1, GetFocusedWindowId()); |
792 | 792 |
793 FocusWindowById(1); | 793 FocusWindowById(1); |
794 | 794 |
795 EXPECT_EQ(1, GetActiveWindowId()); | 795 EXPECT_EQ(1, GetActiveWindowId()); |
796 EXPECT_EQ(1, GetFocusedWindowId()); | 796 EXPECT_EQ(1, GetFocusedWindowId()); |
797 | 797 |
798 aura::client::GetCaptureClient(root_window())->ReleaseCapture(w1); | 798 aura::client::GetCaptureClient(root_window())->ReleaseCapture(w1); |
799 } | 799 } |
800 | 800 |
801 // Verifies if a window that loses activation or focus is deleted during | 801 // Verifies if a window that loses activation or focus is deleted during |
802 // observer notification we don't pass the deleted window to other observers. | 802 // observer notification we don't pass the deleted window to other observers. |
803 virtual void DontPassDeletedWindow() OVERRIDE { | 803 virtual void DontPassDeletedWindow() override { |
804 FocusWindowById(1); | 804 FocusWindowById(1); |
805 | 805 |
806 EXPECT_EQ(1, GetActiveWindowId()); | 806 EXPECT_EQ(1, GetActiveWindowId()); |
807 EXPECT_EQ(1, GetFocusedWindowId()); | 807 EXPECT_EQ(1, GetFocusedWindowId()); |
808 | 808 |
809 { | 809 { |
810 aura::Window* to_delete = root_window()->GetChildById(1); | 810 aura::Window* to_delete = root_window()->GetChildById(1); |
811 DeleteOnLoseActivationChangeObserver observer1(to_delete); | 811 DeleteOnLoseActivationChangeObserver observer1(to_delete); |
812 RecordingActivationAndFocusChangeObserver observer2(root_window(), | 812 RecordingActivationAndFocusChangeObserver observer2(root_window(), |
813 &observer1); | 813 &observer1); |
(...skipping 18 matching lines...) Expand all Loading... |
832 EXPECT_EQ(3, GetActiveWindowId()); | 832 EXPECT_EQ(3, GetActiveWindowId()); |
833 EXPECT_EQ(3, GetFocusedWindowId()); | 833 EXPECT_EQ(3, GetFocusedWindowId()); |
834 | 834 |
835 EXPECT_EQ(to_delete, observer1.GetDeletedWindow()); | 835 EXPECT_EQ(to_delete, observer1.GetDeletedWindow()); |
836 EXPECT_FALSE(observer2.was_notified_with_deleted_window()); | 836 EXPECT_FALSE(observer2.was_notified_with_deleted_window()); |
837 } | 837 } |
838 } | 838 } |
839 | 839 |
840 // Verifies if the focused text input client is cleared when a window gains | 840 // Verifies if the focused text input client is cleared when a window gains |
841 // or loses the focus. | 841 // or loses the focus. |
842 virtual void FocusedTextInputClient() OVERRIDE { | 842 virtual void FocusedTextInputClient() override { |
843 ui::TextInputFocusManager* text_input_focus_manager = | 843 ui::TextInputFocusManager* text_input_focus_manager = |
844 ui::TextInputFocusManager::GetInstance(); | 844 ui::TextInputFocusManager::GetInstance(); |
845 ui::DummyTextInputClient text_input_client; | 845 ui::DummyTextInputClient text_input_client; |
846 ui::TextInputClient* null_text_input_client = NULL; | 846 ui::TextInputClient* null_text_input_client = NULL; |
847 | 847 |
848 EXPECT_EQ(null_text_input_client, | 848 EXPECT_EQ(null_text_input_client, |
849 text_input_focus_manager->GetFocusedTextInputClient()); | 849 text_input_focus_manager->GetFocusedTextInputClient()); |
850 | 850 |
851 text_input_focus_manager->FocusTextInputClient(&text_input_client); | 851 text_input_focus_manager->FocusTextInputClient(&text_input_client); |
852 EXPECT_EQ(&text_input_client, | 852 EXPECT_EQ(&text_input_client, |
(...skipping 23 matching lines...) Expand all Loading... |
876 DISALLOW_COPY_AND_ASSIGN(FocusControllerDirectTestBase); | 876 DISALLOW_COPY_AND_ASSIGN(FocusControllerDirectTestBase); |
877 }; | 877 }; |
878 | 878 |
879 // Focus and Activation changes via aura::client::ActivationClient API. | 879 // Focus and Activation changes via aura::client::ActivationClient API. |
880 class FocusControllerApiTest : public FocusControllerDirectTestBase { | 880 class FocusControllerApiTest : public FocusControllerDirectTestBase { |
881 public: | 881 public: |
882 FocusControllerApiTest() {} | 882 FocusControllerApiTest() {} |
883 | 883 |
884 private: | 884 private: |
885 // Overridden from FocusControllerTestBase: | 885 // Overridden from FocusControllerTestBase: |
886 virtual void FocusWindowDirect(aura::Window* window) OVERRIDE { | 886 virtual void FocusWindowDirect(aura::Window* window) override { |
887 FocusWindow(window); | 887 FocusWindow(window); |
888 } | 888 } |
889 virtual void ActivateWindowDirect(aura::Window* window) OVERRIDE { | 889 virtual void ActivateWindowDirect(aura::Window* window) override { |
890 ActivateWindow(window); | 890 ActivateWindow(window); |
891 } | 891 } |
892 virtual void DeactivateWindowDirect(aura::Window* window) OVERRIDE { | 892 virtual void DeactivateWindowDirect(aura::Window* window) override { |
893 DeactivateWindow(window); | 893 DeactivateWindow(window); |
894 } | 894 } |
895 virtual bool IsInputEvent() OVERRIDE { return false; } | 895 virtual bool IsInputEvent() override { return false; } |
896 | 896 |
897 DISALLOW_COPY_AND_ASSIGN(FocusControllerApiTest); | 897 DISALLOW_COPY_AND_ASSIGN(FocusControllerApiTest); |
898 }; | 898 }; |
899 | 899 |
900 // Focus and Activation changes via input events. | 900 // Focus and Activation changes via input events. |
901 class FocusControllerMouseEventTest : public FocusControllerDirectTestBase { | 901 class FocusControllerMouseEventTest : public FocusControllerDirectTestBase { |
902 public: | 902 public: |
903 FocusControllerMouseEventTest() {} | 903 FocusControllerMouseEventTest() {} |
904 | 904 |
905 // Tests that a handled mouse or gesture event does not trigger a window | 905 // Tests that a handled mouse or gesture event does not trigger a window |
906 // activation. | 906 // activation. |
907 void IgnoreHandledEvent() { | 907 void IgnoreHandledEvent() { |
908 EXPECT_EQ(NULL, GetActiveWindow()); | 908 EXPECT_EQ(NULL, GetActiveWindow()); |
909 aura::Window* w1 = root_window()->GetChildById(1); | 909 aura::Window* w1 = root_window()->GetChildById(1); |
910 SimpleEventHandler handler; | 910 SimpleEventHandler handler; |
911 root_window()->PrependPreTargetHandler(&handler); | 911 root_window()->PrependPreTargetHandler(&handler); |
912 ui::test::EventGenerator generator(root_window(), w1); | 912 ui::test::EventGenerator generator(root_window(), w1); |
913 generator.ClickLeftButton(); | 913 generator.ClickLeftButton(); |
914 EXPECT_EQ(NULL, GetActiveWindow()); | 914 EXPECT_EQ(NULL, GetActiveWindow()); |
915 generator.GestureTapAt(w1->bounds().CenterPoint()); | 915 generator.GestureTapAt(w1->bounds().CenterPoint()); |
916 EXPECT_EQ(NULL, GetActiveWindow()); | 916 EXPECT_EQ(NULL, GetActiveWindow()); |
917 root_window()->RemovePreTargetHandler(&handler); | 917 root_window()->RemovePreTargetHandler(&handler); |
918 generator.ClickLeftButton(); | 918 generator.ClickLeftButton(); |
919 EXPECT_EQ(1, GetActiveWindowId()); | 919 EXPECT_EQ(1, GetActiveWindowId()); |
920 } | 920 } |
921 | 921 |
922 private: | 922 private: |
923 // Overridden from FocusControllerTestBase: | 923 // Overridden from FocusControllerTestBase: |
924 virtual void FocusWindowDirect(aura::Window* window) OVERRIDE { | 924 virtual void FocusWindowDirect(aura::Window* window) override { |
925 ui::test::EventGenerator generator(root_window(), window); | 925 ui::test::EventGenerator generator(root_window(), window); |
926 generator.ClickLeftButton(); | 926 generator.ClickLeftButton(); |
927 } | 927 } |
928 virtual void ActivateWindowDirect(aura::Window* window) OVERRIDE { | 928 virtual void ActivateWindowDirect(aura::Window* window) override { |
929 ui::test::EventGenerator generator(root_window(), window); | 929 ui::test::EventGenerator generator(root_window(), window); |
930 generator.ClickLeftButton(); | 930 generator.ClickLeftButton(); |
931 } | 931 } |
932 virtual void DeactivateWindowDirect(aura::Window* window) OVERRIDE { | 932 virtual void DeactivateWindowDirect(aura::Window* window) override { |
933 aura::Window* next_activatable = | 933 aura::Window* next_activatable = |
934 test_focus_rules()->GetNextActivatableWindow(window); | 934 test_focus_rules()->GetNextActivatableWindow(window); |
935 ui::test::EventGenerator generator(root_window(), next_activatable); | 935 ui::test::EventGenerator generator(root_window(), next_activatable); |
936 generator.ClickLeftButton(); | 936 generator.ClickLeftButton(); |
937 } | 937 } |
938 virtual bool IsInputEvent() OVERRIDE { return true; } | 938 virtual bool IsInputEvent() override { return true; } |
939 | 939 |
940 DISALLOW_COPY_AND_ASSIGN(FocusControllerMouseEventTest); | 940 DISALLOW_COPY_AND_ASSIGN(FocusControllerMouseEventTest); |
941 }; | 941 }; |
942 | 942 |
943 class FocusControllerGestureEventTest : public FocusControllerDirectTestBase { | 943 class FocusControllerGestureEventTest : public FocusControllerDirectTestBase { |
944 public: | 944 public: |
945 FocusControllerGestureEventTest() {} | 945 FocusControllerGestureEventTest() {} |
946 | 946 |
947 private: | 947 private: |
948 // Overridden from FocusControllerTestBase: | 948 // Overridden from FocusControllerTestBase: |
949 virtual void FocusWindowDirect(aura::Window* window) OVERRIDE { | 949 virtual void FocusWindowDirect(aura::Window* window) override { |
950 ui::test::EventGenerator generator(root_window(), window); | 950 ui::test::EventGenerator generator(root_window(), window); |
951 generator.GestureTapAt(window->bounds().CenterPoint()); | 951 generator.GestureTapAt(window->bounds().CenterPoint()); |
952 } | 952 } |
953 virtual void ActivateWindowDirect(aura::Window* window) OVERRIDE { | 953 virtual void ActivateWindowDirect(aura::Window* window) override { |
954 ui::test::EventGenerator generator(root_window(), window); | 954 ui::test::EventGenerator generator(root_window(), window); |
955 generator.GestureTapAt(window->bounds().CenterPoint()); | 955 generator.GestureTapAt(window->bounds().CenterPoint()); |
956 } | 956 } |
957 virtual void DeactivateWindowDirect(aura::Window* window) OVERRIDE { | 957 virtual void DeactivateWindowDirect(aura::Window* window) override { |
958 aura::Window* next_activatable = | 958 aura::Window* next_activatable = |
959 test_focus_rules()->GetNextActivatableWindow(window); | 959 test_focus_rules()->GetNextActivatableWindow(window); |
960 ui::test::EventGenerator generator(root_window(), next_activatable); | 960 ui::test::EventGenerator generator(root_window(), next_activatable); |
961 generator.GestureTapAt(window->bounds().CenterPoint()); | 961 generator.GestureTapAt(window->bounds().CenterPoint()); |
962 } | 962 } |
963 virtual bool IsInputEvent() OVERRIDE { return true; } | 963 virtual bool IsInputEvent() override { return true; } |
964 | 964 |
965 DISALLOW_COPY_AND_ASSIGN(FocusControllerGestureEventTest); | 965 DISALLOW_COPY_AND_ASSIGN(FocusControllerGestureEventTest); |
966 }; | 966 }; |
967 | 967 |
968 // Test base for tests where focus is implicitly set to a window as the result | 968 // Test base for tests where focus is implicitly set to a window as the result |
969 // of a disposition change to the focused window or the hierarchy that contains | 969 // of a disposition change to the focused window or the hierarchy that contains |
970 // it. | 970 // it. |
971 class FocusControllerImplicitTestBase : public FocusControllerTestBase { | 971 class FocusControllerImplicitTestBase : public FocusControllerTestBase { |
972 protected: | 972 protected: |
973 explicit FocusControllerImplicitTestBase(bool parent) : parent_(parent) {} | 973 explicit FocusControllerImplicitTestBase(bool parent) : parent_(parent) {} |
974 | 974 |
975 aura::Window* GetDispositionWindow(aura::Window* window) { | 975 aura::Window* GetDispositionWindow(aura::Window* window) { |
976 return parent_ ? window->parent() : window; | 976 return parent_ ? window->parent() : window; |
977 } | 977 } |
978 | 978 |
979 // Change the disposition of |window| in such a way as it will lose focus. | 979 // Change the disposition of |window| in such a way as it will lose focus. |
980 virtual void ChangeWindowDisposition(aura::Window* window) = 0; | 980 virtual void ChangeWindowDisposition(aura::Window* window) = 0; |
981 | 981 |
982 // Allow each disposition change test to add additional post-disposition | 982 // Allow each disposition change test to add additional post-disposition |
983 // change expectations. | 983 // change expectations. |
984 virtual void PostDispostionChangeExpectations() {} | 984 virtual void PostDispostionChangeExpectations() {} |
985 | 985 |
986 // Overridden from FocusControllerTestBase: | 986 // Overridden from FocusControllerTestBase: |
987 virtual void BasicFocus() OVERRIDE { | 987 virtual void BasicFocus() override { |
988 EXPECT_EQ(NULL, GetFocusedWindow()); | 988 EXPECT_EQ(NULL, GetFocusedWindow()); |
989 | 989 |
990 aura::Window* w211 = root_window()->GetChildById(211); | 990 aura::Window* w211 = root_window()->GetChildById(211); |
991 FocusWindow(w211); | 991 FocusWindow(w211); |
992 EXPECT_EQ(211, GetFocusedWindowId()); | 992 EXPECT_EQ(211, GetFocusedWindowId()); |
993 | 993 |
994 ChangeWindowDisposition(w211); | 994 ChangeWindowDisposition(w211); |
995 // BasicFocusRules passes focus to the parent. | 995 // BasicFocusRules passes focus to the parent. |
996 EXPECT_EQ(parent_ ? 2 : 21, GetFocusedWindowId()); | 996 EXPECT_EQ(parent_ ? 2 : 21, GetFocusedWindowId()); |
997 } | 997 } |
998 virtual void BasicActivation() OVERRIDE { | 998 virtual void BasicActivation() override { |
999 DCHECK(!parent_) << "Activation tests don't support parent changes."; | 999 DCHECK(!parent_) << "Activation tests don't support parent changes."; |
1000 | 1000 |
1001 EXPECT_EQ(NULL, GetActiveWindow()); | 1001 EXPECT_EQ(NULL, GetActiveWindow()); |
1002 | 1002 |
1003 aura::Window* w2 = root_window()->GetChildById(2); | 1003 aura::Window* w2 = root_window()->GetChildById(2); |
1004 ActivateWindow(w2); | 1004 ActivateWindow(w2); |
1005 EXPECT_EQ(2, GetActiveWindowId()); | 1005 EXPECT_EQ(2, GetActiveWindowId()); |
1006 | 1006 |
1007 ChangeWindowDisposition(w2); | 1007 ChangeWindowDisposition(w2); |
1008 EXPECT_EQ(3, GetActiveWindowId()); | 1008 EXPECT_EQ(3, GetActiveWindowId()); |
1009 PostDispostionChangeExpectations(); | 1009 PostDispostionChangeExpectations(); |
1010 } | 1010 } |
1011 virtual void FocusEvents() OVERRIDE { | 1011 virtual void FocusEvents() override { |
1012 aura::Window* w211 = root_window()->GetChildById(211); | 1012 aura::Window* w211 = root_window()->GetChildById(211); |
1013 FocusWindow(w211); | 1013 FocusWindow(w211); |
1014 | 1014 |
1015 ScopedFocusNotificationObserver root_observer(root_window()); | 1015 ScopedFocusNotificationObserver root_observer(root_window()); |
1016 ScopedTargetFocusNotificationObserver observer211(root_window(), 211); | 1016 ScopedTargetFocusNotificationObserver observer211(root_window(), 211); |
1017 root_observer.ExpectCounts(0, 0); | 1017 root_observer.ExpectCounts(0, 0); |
1018 observer211.ExpectCounts(0, 0); | 1018 observer211.ExpectCounts(0, 0); |
1019 | 1019 |
1020 ChangeWindowDisposition(w211); | 1020 ChangeWindowDisposition(w211); |
1021 root_observer.ExpectCounts(0, 1); | 1021 root_observer.ExpectCounts(0, 1); |
1022 observer211.ExpectCounts(0, 1); | 1022 observer211.ExpectCounts(0, 1); |
1023 } | 1023 } |
1024 virtual void ActivationEvents() OVERRIDE { | 1024 virtual void ActivationEvents() override { |
1025 DCHECK(!parent_) << "Activation tests don't support parent changes."; | 1025 DCHECK(!parent_) << "Activation tests don't support parent changes."; |
1026 | 1026 |
1027 aura::Window* w2 = root_window()->GetChildById(2); | 1027 aura::Window* w2 = root_window()->GetChildById(2); |
1028 ActivateWindow(w2); | 1028 ActivateWindow(w2); |
1029 | 1029 |
1030 ScopedFocusNotificationObserver root_observer(root_window()); | 1030 ScopedFocusNotificationObserver root_observer(root_window()); |
1031 ScopedTargetFocusNotificationObserver observer2(root_window(), 2); | 1031 ScopedTargetFocusNotificationObserver observer2(root_window(), 2); |
1032 ScopedTargetFocusNotificationObserver observer3(root_window(), 3); | 1032 ScopedTargetFocusNotificationObserver observer3(root_window(), 3); |
1033 root_observer.ExpectCounts(0, 0); | 1033 root_observer.ExpectCounts(0, 0); |
1034 observer2.ExpectCounts(0, 0); | 1034 observer2.ExpectCounts(0, 0); |
1035 observer3.ExpectCounts(0, 0); | 1035 observer3.ExpectCounts(0, 0); |
1036 | 1036 |
1037 ChangeWindowDisposition(w2); | 1037 ChangeWindowDisposition(w2); |
1038 root_observer.ExpectCounts(1, 1); | 1038 root_observer.ExpectCounts(1, 1); |
1039 observer2.ExpectCounts(1, 1); | 1039 observer2.ExpectCounts(1, 1); |
1040 observer3.ExpectCounts(1, 1); | 1040 observer3.ExpectCounts(1, 1); |
1041 } | 1041 } |
1042 virtual void FocusRulesOverride() OVERRIDE { | 1042 virtual void FocusRulesOverride() override { |
1043 EXPECT_EQ(NULL, GetFocusedWindow()); | 1043 EXPECT_EQ(NULL, GetFocusedWindow()); |
1044 aura::Window* w211 = root_window()->GetChildById(211); | 1044 aura::Window* w211 = root_window()->GetChildById(211); |
1045 FocusWindow(w211); | 1045 FocusWindow(w211); |
1046 EXPECT_EQ(211, GetFocusedWindowId()); | 1046 EXPECT_EQ(211, GetFocusedWindowId()); |
1047 | 1047 |
1048 test_focus_rules()->set_focus_restriction(root_window()->GetChildById(11)); | 1048 test_focus_rules()->set_focus_restriction(root_window()->GetChildById(11)); |
1049 ChangeWindowDisposition(w211); | 1049 ChangeWindowDisposition(w211); |
1050 // Normally, focus would shift to the parent (w21) but the override shifts | 1050 // Normally, focus would shift to the parent (w21) but the override shifts |
1051 // it to 11. | 1051 // it to 11. |
1052 EXPECT_EQ(11, GetFocusedWindowId()); | 1052 EXPECT_EQ(11, GetFocusedWindowId()); |
1053 | 1053 |
1054 test_focus_rules()->set_focus_restriction(NULL); | 1054 test_focus_rules()->set_focus_restriction(NULL); |
1055 } | 1055 } |
1056 virtual void ActivationRulesOverride() OVERRIDE { | 1056 virtual void ActivationRulesOverride() override { |
1057 DCHECK(!parent_) << "Activation tests don't support parent changes."; | 1057 DCHECK(!parent_) << "Activation tests don't support parent changes."; |
1058 | 1058 |
1059 aura::Window* w1 = root_window()->GetChildById(1); | 1059 aura::Window* w1 = root_window()->GetChildById(1); |
1060 ActivateWindow(w1); | 1060 ActivateWindow(w1); |
1061 | 1061 |
1062 EXPECT_EQ(1, GetActiveWindowId()); | 1062 EXPECT_EQ(1, GetActiveWindowId()); |
1063 EXPECT_EQ(1, GetFocusedWindowId()); | 1063 EXPECT_EQ(1, GetFocusedWindowId()); |
1064 | 1064 |
1065 aura::Window* w3 = root_window()->GetChildById(3); | 1065 aura::Window* w3 = root_window()->GetChildById(3); |
1066 test_focus_rules()->set_focus_restriction(w3); | 1066 test_focus_rules()->set_focus_restriction(w3); |
(...skipping 22 matching lines...) Expand all Loading... |
1089 // Focus and Activation changes in response to window visibility changes. | 1089 // Focus and Activation changes in response to window visibility changes. |
1090 class FocusControllerHideTest : public FocusControllerImplicitTestBase { | 1090 class FocusControllerHideTest : public FocusControllerImplicitTestBase { |
1091 public: | 1091 public: |
1092 FocusControllerHideTest() : FocusControllerImplicitTestBase(false) {} | 1092 FocusControllerHideTest() : FocusControllerImplicitTestBase(false) {} |
1093 | 1093 |
1094 protected: | 1094 protected: |
1095 FocusControllerHideTest(bool parent) | 1095 FocusControllerHideTest(bool parent) |
1096 : FocusControllerImplicitTestBase(parent) {} | 1096 : FocusControllerImplicitTestBase(parent) {} |
1097 | 1097 |
1098 // Overridden from FocusControllerImplicitTestBase: | 1098 // Overridden from FocusControllerImplicitTestBase: |
1099 virtual void ChangeWindowDisposition(aura::Window* window) OVERRIDE { | 1099 virtual void ChangeWindowDisposition(aura::Window* window) override { |
1100 GetDispositionWindow(window)->Hide(); | 1100 GetDispositionWindow(window)->Hide(); |
1101 } | 1101 } |
1102 | 1102 |
1103 private: | 1103 private: |
1104 DISALLOW_COPY_AND_ASSIGN(FocusControllerHideTest); | 1104 DISALLOW_COPY_AND_ASSIGN(FocusControllerHideTest); |
1105 }; | 1105 }; |
1106 | 1106 |
1107 // Focus and Activation changes in response to window parent visibility | 1107 // Focus and Activation changes in response to window parent visibility |
1108 // changes. | 1108 // changes. |
1109 class FocusControllerParentHideTest : public FocusControllerHideTest { | 1109 class FocusControllerParentHideTest : public FocusControllerHideTest { |
1110 public: | 1110 public: |
1111 FocusControllerParentHideTest() : FocusControllerHideTest(true) {} | 1111 FocusControllerParentHideTest() : FocusControllerHideTest(true) {} |
1112 | 1112 |
1113 private: | 1113 private: |
1114 DISALLOW_COPY_AND_ASSIGN(FocusControllerParentHideTest); | 1114 DISALLOW_COPY_AND_ASSIGN(FocusControllerParentHideTest); |
1115 }; | 1115 }; |
1116 | 1116 |
1117 // Focus and Activation changes in response to window destruction. | 1117 // Focus and Activation changes in response to window destruction. |
1118 class FocusControllerDestructionTest : public FocusControllerImplicitTestBase { | 1118 class FocusControllerDestructionTest : public FocusControllerImplicitTestBase { |
1119 public: | 1119 public: |
1120 FocusControllerDestructionTest() : FocusControllerImplicitTestBase(false) {} | 1120 FocusControllerDestructionTest() : FocusControllerImplicitTestBase(false) {} |
1121 | 1121 |
1122 protected: | 1122 protected: |
1123 FocusControllerDestructionTest(bool parent) | 1123 FocusControllerDestructionTest(bool parent) |
1124 : FocusControllerImplicitTestBase(parent) {} | 1124 : FocusControllerImplicitTestBase(parent) {} |
1125 | 1125 |
1126 // Overridden from FocusControllerImplicitTestBase: | 1126 // Overridden from FocusControllerImplicitTestBase: |
1127 virtual void ChangeWindowDisposition(aura::Window* window) OVERRIDE { | 1127 virtual void ChangeWindowDisposition(aura::Window* window) override { |
1128 delete GetDispositionWindow(window); | 1128 delete GetDispositionWindow(window); |
1129 } | 1129 } |
1130 | 1130 |
1131 private: | 1131 private: |
1132 DISALLOW_COPY_AND_ASSIGN(FocusControllerDestructionTest); | 1132 DISALLOW_COPY_AND_ASSIGN(FocusControllerDestructionTest); |
1133 }; | 1133 }; |
1134 | 1134 |
1135 // Focus and Activation changes in response to window parent destruction. | 1135 // Focus and Activation changes in response to window parent destruction. |
1136 class FocusControllerParentDestructionTest | 1136 class FocusControllerParentDestructionTest |
1137 : public FocusControllerDestructionTest { | 1137 : public FocusControllerDestructionTest { |
1138 public: | 1138 public: |
1139 FocusControllerParentDestructionTest() | 1139 FocusControllerParentDestructionTest() |
1140 : FocusControllerDestructionTest(true) {} | 1140 : FocusControllerDestructionTest(true) {} |
1141 | 1141 |
1142 private: | 1142 private: |
1143 DISALLOW_COPY_AND_ASSIGN(FocusControllerParentDestructionTest); | 1143 DISALLOW_COPY_AND_ASSIGN(FocusControllerParentDestructionTest); |
1144 }; | 1144 }; |
1145 | 1145 |
1146 // Focus and Activation changes in response to window removal. | 1146 // Focus and Activation changes in response to window removal. |
1147 class FocusControllerRemovalTest : public FocusControllerImplicitTestBase { | 1147 class FocusControllerRemovalTest : public FocusControllerImplicitTestBase { |
1148 public: | 1148 public: |
1149 FocusControllerRemovalTest() : FocusControllerImplicitTestBase(false) {} | 1149 FocusControllerRemovalTest() : FocusControllerImplicitTestBase(false) {} |
1150 | 1150 |
1151 protected: | 1151 protected: |
1152 FocusControllerRemovalTest(bool parent) | 1152 FocusControllerRemovalTest(bool parent) |
1153 : FocusControllerImplicitTestBase(parent) {} | 1153 : FocusControllerImplicitTestBase(parent) {} |
1154 | 1154 |
1155 // Overridden from FocusControllerImplicitTestBase: | 1155 // Overridden from FocusControllerImplicitTestBase: |
1156 virtual void ChangeWindowDisposition(aura::Window* window) OVERRIDE { | 1156 virtual void ChangeWindowDisposition(aura::Window* window) override { |
1157 aura::Window* disposition_window = GetDispositionWindow(window); | 1157 aura::Window* disposition_window = GetDispositionWindow(window); |
1158 disposition_window->parent()->RemoveChild(disposition_window); | 1158 disposition_window->parent()->RemoveChild(disposition_window); |
1159 window_owner_.reset(disposition_window); | 1159 window_owner_.reset(disposition_window); |
1160 } | 1160 } |
1161 virtual void TearDown() OVERRIDE { | 1161 virtual void TearDown() override { |
1162 window_owner_.reset(); | 1162 window_owner_.reset(); |
1163 FocusControllerImplicitTestBase::TearDown(); | 1163 FocusControllerImplicitTestBase::TearDown(); |
1164 } | 1164 } |
1165 | 1165 |
1166 private: | 1166 private: |
1167 scoped_ptr<aura::Window> window_owner_; | 1167 scoped_ptr<aura::Window> window_owner_; |
1168 | 1168 |
1169 DISALLOW_COPY_AND_ASSIGN(FocusControllerRemovalTest); | 1169 DISALLOW_COPY_AND_ASSIGN(FocusControllerRemovalTest); |
1170 }; | 1170 }; |
1171 | 1171 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1276 FOCUS_CONTROLLER_TEST(FocusControllerApiTest, DontPassDeletedWindow); | 1276 FOCUS_CONTROLLER_TEST(FocusControllerApiTest, DontPassDeletedWindow); |
1277 | 1277 |
1278 // - Verifies that the focused text input client is cleard when the window focus | 1278 // - Verifies that the focused text input client is cleard when the window focus |
1279 // changes. | 1279 // changes. |
1280 ALL_FOCUS_TESTS(FocusedTextInputClient); | 1280 ALL_FOCUS_TESTS(FocusedTextInputClient); |
1281 | 1281 |
1282 // If a mouse event was handled, it should not activate a window. | 1282 // If a mouse event was handled, it should not activate a window. |
1283 FOCUS_CONTROLLER_TEST(FocusControllerMouseEventTest, IgnoreHandledEvent); | 1283 FOCUS_CONTROLLER_TEST(FocusControllerMouseEventTest, IgnoreHandledEvent); |
1284 | 1284 |
1285 } // namespace wm | 1285 } // namespace wm |
OLD | NEW |