| 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/views/corewm/focus_controller.h" | 5 #include "ui/views/corewm/focus_controller.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "ui/aura/client/activation_client.h" | 9 #include "ui/aura/client/activation_client.h" |
| 10 #include "ui/aura/root_window.h" | 10 #include "ui/aura/root_window.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 FocusControllerTestBase() {} | 131 FocusControllerTestBase() {} |
| 132 | 132 |
| 133 // Overridden from aura::test::AuraTestBase: | 133 // Overridden from aura::test::AuraTestBase: |
| 134 virtual void SetUp() OVERRIDE { | 134 virtual void SetUp() OVERRIDE { |
| 135 // FocusController registers itself as an Env observer so it can catch all | 135 // FocusController registers itself as an Env observer so it can catch all |
| 136 // window initializations, including the root_window()'s, so we create it | 136 // window initializations, including the root_window()'s, so we create it |
| 137 // before allowing the base setup. | 137 // before allowing the base setup. |
| 138 test_focus_rules_ = new TestFocusRules; | 138 test_focus_rules_ = new TestFocusRules; |
| 139 focus_controller_.reset(new FocusController(test_focus_rules_)); | 139 focus_controller_.reset(new FocusController(test_focus_rules_)); |
| 140 aura::test::AuraTestBase::SetUp(); | 140 aura::test::AuraTestBase::SetUp(); |
| 141 root_window()->AddPreTargetHandler(focus_controller()); | 141 root_window()->AddPreTargetHandler(focus_controller_.get()); |
| 142 aura::client::SetActivationClient(root_window(), focus_controller()); | 142 aura::client::SetFocusClient(root_window(), focus_controller_.get()); |
| 143 aura::client::SetActivationClient(root_window(), focus_controller_.get()); |
| 143 | 144 |
| 144 // Hierarchy used by all tests: | 145 // Hierarchy used by all tests: |
| 145 // root_window | 146 // root_window |
| 146 // +-- w1 | 147 // +-- w1 |
| 147 // | +-- w11 | 148 // | +-- w11 |
| 148 // | +-- w12 | 149 // | +-- w12 |
| 149 // +-- w2 | 150 // +-- w2 |
| 150 // | +-- w21 | 151 // | +-- w21 |
| 151 // | +-- w211 | 152 // | +-- w211 |
| 152 // +-- w3 | 153 // +-- w3 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 166 aura::test::TestWindowDelegate::CreateSelfDestroyingDelegate(), 21, | 167 aura::test::TestWindowDelegate::CreateSelfDestroyingDelegate(), 21, |
| 167 gfx::Rect(5, 5, 10, 10), w2); | 168 gfx::Rect(5, 5, 10, 10), w2); |
| 168 aura::test::CreateTestWindowWithDelegate( | 169 aura::test::CreateTestWindowWithDelegate( |
| 169 aura::test::TestWindowDelegate::CreateSelfDestroyingDelegate(), 211, | 170 aura::test::TestWindowDelegate::CreateSelfDestroyingDelegate(), 211, |
| 170 gfx::Rect(1, 1, 5, 5), w21); | 171 gfx::Rect(1, 1, 5, 5), w21); |
| 171 aura::test::CreateTestWindowWithDelegate( | 172 aura::test::CreateTestWindowWithDelegate( |
| 172 aura::test::TestWindowDelegate::CreateSelfDestroyingDelegate(), 3, | 173 aura::test::TestWindowDelegate::CreateSelfDestroyingDelegate(), 3, |
| 173 gfx::Rect(125, 125, 50, 50), root_window()); | 174 gfx::Rect(125, 125, 50, 50), root_window()); |
| 174 } | 175 } |
| 175 virtual void TearDown() OVERRIDE { | 176 virtual void TearDown() OVERRIDE { |
| 176 root_window()->RemovePreTargetHandler(focus_controller()); | 177 root_window()->RemovePreTargetHandler(focus_controller_.get()); |
| 177 aura::test::AuraTestBase::TearDown(); | 178 aura::test::AuraTestBase::TearDown(); |
| 178 test_focus_rules_ = NULL; // Owned by FocusController. | 179 test_focus_rules_ = NULL; // Owned by FocusController. |
| 179 focus_controller_.reset(); | 180 focus_controller_.reset(); |
| 180 } | 181 } |
| 181 | 182 |
| 182 FocusController* focus_controller() { return focus_controller_.get(); } | 183 void FocusWindow(aura::Window* window) { |
| 183 aura::Window* focused_window() { return focus_controller_->focused_window(); } | 184 aura::client::GetFocusClient(root_window())->FocusWindow(window, NULL); |
| 184 int focused_window_id() { | |
| 185 return focused_window() ? focused_window()->id() : -1; | |
| 186 } | 185 } |
| 187 | 186 aura::Window* GetFocusedWindow() { |
| 187 return aura::client::GetFocusClient(root_window())->GetFocusedWindow(); |
| 188 } |
| 189 int GetFocusedWindowId() { |
| 190 return GetFocusedWindow()->id(); |
| 191 } |
| 188 void ActivateWindow(aura::Window* window) { | 192 void ActivateWindow(aura::Window* window) { |
| 189 aura::client::GetActivationClient(root_window())->ActivateWindow(window); | 193 aura::client::GetActivationClient(root_window())->ActivateWindow(window); |
| 190 } | 194 } |
| 191 void DeactivateWindow(aura::Window* window) { | 195 void DeactivateWindow(aura::Window* window) { |
| 192 aura::client::GetActivationClient(root_window())->DeactivateWindow(window); | 196 aura::client::GetActivationClient(root_window())->DeactivateWindow(window); |
| 193 } | 197 } |
| 194 aura::Window* GetActiveWindow() { | 198 aura::Window* GetActiveWindow() { |
| 195 return aura::client::GetActivationClient(root_window())->GetActiveWindow(); | 199 return aura::client::GetActivationClient(root_window())->GetActiveWindow(); |
| 196 } | 200 } |
| 197 int GetActiveWindowId() { | 201 int GetActiveWindowId() { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 FocusWindowDirect(window); | 251 FocusWindowDirect(window); |
| 248 } | 252 } |
| 249 void ActivateWindowById(int id) { | 253 void ActivateWindowById(int id) { |
| 250 aura::Window* window = root_window()->GetChildById(id); | 254 aura::Window* window = root_window()->GetChildById(id); |
| 251 DCHECK(window); | 255 DCHECK(window); |
| 252 ActivateWindowDirect(window); | 256 ActivateWindowDirect(window); |
| 253 } | 257 } |
| 254 | 258 |
| 255 // Overridden from FocusControllerTestBase: | 259 // Overridden from FocusControllerTestBase: |
| 256 virtual void BasicFocus() OVERRIDE { | 260 virtual void BasicFocus() OVERRIDE { |
| 257 EXPECT_EQ(NULL, focused_window()); | 261 EXPECT_EQ(NULL, GetFocusedWindow()); |
| 258 FocusWindowById(1); | 262 FocusWindowById(1); |
| 259 EXPECT_EQ(1, focused_window_id()); | 263 EXPECT_EQ(1, GetFocusedWindowId()); |
| 260 FocusWindowById(2); | 264 FocusWindowById(2); |
| 261 EXPECT_EQ(2, focused_window_id()); | 265 EXPECT_EQ(2, GetFocusedWindowId()); |
| 262 } | 266 } |
| 263 virtual void BasicActivation() OVERRIDE { | 267 virtual void BasicActivation() OVERRIDE { |
| 264 EXPECT_EQ(NULL, GetActiveWindow()); | 268 EXPECT_EQ(NULL, GetActiveWindow()); |
| 265 ActivateWindowById(1); | 269 ActivateWindowById(1); |
| 266 EXPECT_EQ(1, GetActiveWindowId()); | 270 EXPECT_EQ(1, GetActiveWindowId()); |
| 267 ActivateWindowById(2); | 271 ActivateWindowById(2); |
| 268 EXPECT_EQ(2, GetActiveWindowId()); | 272 EXPECT_EQ(2, GetActiveWindowId()); |
| 269 DeactivateWindow(GetActiveWindow()); | 273 DeactivateWindow(GetActiveWindow()); |
| 270 EXPECT_EQ(1, GetActiveWindowId()); | 274 EXPECT_EQ(1, GetActiveWindowId()); |
| 271 } | 275 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 FocusEventsTestHandler handler_root(root_window()); | 325 FocusEventsTestHandler handler_root(root_window()); |
| 322 ExpectActivationEvents(&handler_root, 0, 0); | 326 ExpectActivationEvents(&handler_root, 0, 0); |
| 323 ActivateWindowById(2); | 327 ActivateWindowById(2); |
| 324 ExpectActivationEvents(&handler_root, 1, 1); | 328 ExpectActivationEvents(&handler_root, 1, 1); |
| 325 ActivateWindowById(2); | 329 ActivateWindowById(2); |
| 326 ExpectActivationEvents(&handler_root, 1, 1); | 330 ExpectActivationEvents(&handler_root, 1, 1); |
| 327 } | 331 } |
| 328 virtual void ShiftFocusWithinActiveWindow() OVERRIDE { | 332 virtual void ShiftFocusWithinActiveWindow() OVERRIDE { |
| 329 ActivateWindowById(1); | 333 ActivateWindowById(1); |
| 330 EXPECT_EQ(1, GetActiveWindowId()); | 334 EXPECT_EQ(1, GetActiveWindowId()); |
| 331 EXPECT_EQ(1, focused_window_id()); | 335 EXPECT_EQ(1, GetFocusedWindowId()); |
| 332 FocusWindowById(11); | 336 FocusWindowById(11); |
| 333 EXPECT_EQ(11, focused_window_id()); | 337 EXPECT_EQ(11, GetFocusedWindowId()); |
| 334 FocusWindowById(12); | 338 FocusWindowById(12); |
| 335 EXPECT_EQ(12, focused_window_id()); | 339 EXPECT_EQ(12, GetFocusedWindowId()); |
| 336 } | 340 } |
| 337 virtual void ShiftFocusToChildOfInactiveWindow() OVERRIDE { | 341 virtual void ShiftFocusToChildOfInactiveWindow() OVERRIDE { |
| 338 ActivateWindowById(2); | 342 ActivateWindowById(2); |
| 339 EXPECT_EQ(2, GetActiveWindowId()); | 343 EXPECT_EQ(2, GetActiveWindowId()); |
| 340 EXPECT_EQ(2, focused_window_id()); | 344 EXPECT_EQ(2, GetFocusedWindowId()); |
| 341 FocusWindowById(11); | 345 FocusWindowById(11); |
| 342 EXPECT_EQ(1, GetActiveWindowId()); | 346 EXPECT_EQ(1, GetActiveWindowId()); |
| 343 EXPECT_EQ(11, focused_window_id()); | 347 EXPECT_EQ(11, GetFocusedWindowId()); |
| 344 } | 348 } |
| 345 virtual void FocusRulesOverride() OVERRIDE { | 349 virtual void FocusRulesOverride() OVERRIDE { |
| 346 EXPECT_EQ(NULL, focused_window()); | 350 EXPECT_EQ(NULL, GetFocusedWindow()); |
| 347 FocusWindowById(11); | 351 FocusWindowById(11); |
| 348 EXPECT_EQ(11, focused_window_id()); | 352 EXPECT_EQ(11, GetFocusedWindowId()); |
| 349 | 353 |
| 350 test_focus_rules()->set_focus_restriction(root_window()->GetChildById(211)); | 354 test_focus_rules()->set_focus_restriction(root_window()->GetChildById(211)); |
| 351 FocusWindowById(12); | 355 FocusWindowById(12); |
| 352 EXPECT_EQ(211, focused_window_id()); | 356 EXPECT_EQ(211, GetFocusedWindowId()); |
| 353 | 357 |
| 354 test_focus_rules()->set_focus_restriction(NULL); | 358 test_focus_rules()->set_focus_restriction(NULL); |
| 355 FocusWindowById(12); | 359 FocusWindowById(12); |
| 356 EXPECT_EQ(12, focused_window_id()); | 360 EXPECT_EQ(12, GetFocusedWindowId()); |
| 357 } | 361 } |
| 358 virtual void ActivationRulesOverride() OVERRIDE { | 362 virtual void ActivationRulesOverride() OVERRIDE { |
| 359 ActivateWindowById(1); | 363 ActivateWindowById(1); |
| 360 EXPECT_EQ(1, GetActiveWindowId()); | 364 EXPECT_EQ(1, GetActiveWindowId()); |
| 361 EXPECT_EQ(1, focused_window_id()); | 365 EXPECT_EQ(1, GetFocusedWindowId()); |
| 362 | 366 |
| 363 aura::Window* w3 = root_window()->GetChildById(3); | 367 aura::Window* w3 = root_window()->GetChildById(3); |
| 364 test_focus_rules()->set_focus_restriction(w3); | 368 test_focus_rules()->set_focus_restriction(w3); |
| 365 | 369 |
| 366 ActivateWindowById(2); | 370 ActivateWindowById(2); |
| 367 // FocusRules restricts focus and activation to 3. | 371 // FocusRules restricts focus and activation to 3. |
| 368 EXPECT_EQ(3, GetActiveWindowId()); | 372 EXPECT_EQ(3, GetActiveWindowId()); |
| 369 EXPECT_EQ(3, focused_window_id()); | 373 EXPECT_EQ(3, GetFocusedWindowId()); |
| 370 | 374 |
| 371 test_focus_rules()->set_focus_restriction(NULL); | 375 test_focus_rules()->set_focus_restriction(NULL); |
| 372 ActivateWindowById(2); | 376 ActivateWindowById(2); |
| 373 EXPECT_EQ(2, GetActiveWindowId()); | 377 EXPECT_EQ(2, GetActiveWindowId()); |
| 374 EXPECT_EQ(2, focused_window_id()); | 378 EXPECT_EQ(2, GetFocusedWindowId()); |
| 375 } | 379 } |
| 376 | 380 |
| 377 private: | 381 private: |
| 378 DISALLOW_COPY_AND_ASSIGN(FocusControllerDirectTestBase); | 382 DISALLOW_COPY_AND_ASSIGN(FocusControllerDirectTestBase); |
| 379 }; | 383 }; |
| 380 | 384 |
| 381 // Focus and Activation changes via aura::client::ActivationClient API. | 385 // Focus and Activation changes via aura::client::ActivationClient API. |
| 382 class FocusControllerApiTest : public FocusControllerDirectTestBase { | 386 class FocusControllerApiTest : public FocusControllerDirectTestBase { |
| 383 public: | 387 public: |
| 384 FocusControllerApiTest() {} | 388 FocusControllerApiTest() {} |
| 385 | 389 |
| 386 private: | 390 private: |
| 387 // Overridden from FocusControllerTestBase: | 391 // Overridden from FocusControllerTestBase: |
| 388 virtual void FocusWindowDirect(aura::Window* window) OVERRIDE { | 392 virtual void FocusWindowDirect(aura::Window* window) OVERRIDE { |
| 389 focus_controller()->FocusWindow(window); | 393 FocusWindow(window); |
| 390 } | 394 } |
| 391 virtual void ActivateWindowDirect(aura::Window* window) OVERRIDE { | 395 virtual void ActivateWindowDirect(aura::Window* window) OVERRIDE { |
| 392 ActivateWindow(window); | 396 ActivateWindow(window); |
| 393 } | 397 } |
| 394 virtual void DeactivateWindowDirect(aura::Window* window) OVERRIDE { | 398 virtual void DeactivateWindowDirect(aura::Window* window) OVERRIDE { |
| 395 DeactivateWindow(window); | 399 DeactivateWindow(window); |
| 396 } | 400 } |
| 397 | 401 |
| 398 DISALLOW_COPY_AND_ASSIGN(FocusControllerApiTest); | 402 DISALLOW_COPY_AND_ASSIGN(FocusControllerApiTest); |
| 399 }; | 403 }; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 | 460 |
| 457 aura::Window* GetDispositionWindow(aura::Window* window) { | 461 aura::Window* GetDispositionWindow(aura::Window* window) { |
| 458 return parent_ ? window->parent() : window; | 462 return parent_ ? window->parent() : window; |
| 459 } | 463 } |
| 460 | 464 |
| 461 // Change the disposition of |window| in such a way as it will lose focus. | 465 // Change the disposition of |window| in such a way as it will lose focus. |
| 462 virtual void ChangeWindowDisposition(aura::Window* window) = 0; | 466 virtual void ChangeWindowDisposition(aura::Window* window) = 0; |
| 463 | 467 |
| 464 // Overridden from FocusControllerTestBase: | 468 // Overridden from FocusControllerTestBase: |
| 465 virtual void BasicFocus() OVERRIDE { | 469 virtual void BasicFocus() OVERRIDE { |
| 466 EXPECT_EQ(NULL, focused_window()); | 470 EXPECT_EQ(NULL, GetFocusedWindow()); |
| 467 | 471 |
| 468 aura::Window* w211 = root_window()->GetChildById(211); | 472 aura::Window* w211 = root_window()->GetChildById(211); |
| 469 focus_controller()->FocusWindow(w211); | 473 FocusWindow(w211); |
| 470 EXPECT_EQ(211, focused_window_id()); | 474 EXPECT_EQ(211, GetFocusedWindowId()); |
| 471 | 475 |
| 472 ChangeWindowDisposition(w211); | 476 ChangeWindowDisposition(w211); |
| 473 // BasicFocusRules passes focus to the parent. | 477 // BasicFocusRules passes focus to the parent. |
| 474 EXPECT_EQ(parent_ ? 2 : 21, focused_window_id()); | 478 EXPECT_EQ(parent_ ? 2 : 21, GetFocusedWindowId()); |
| 475 } | 479 } |
| 476 virtual void BasicActivation() OVERRIDE { | 480 virtual void BasicActivation() OVERRIDE { |
| 477 DCHECK(!parent_) << "Activation tests don't support parent changes."; | 481 DCHECK(!parent_) << "Activation tests don't support parent changes."; |
| 478 | 482 |
| 479 EXPECT_EQ(NULL, GetActiveWindow()); | 483 EXPECT_EQ(NULL, GetActiveWindow()); |
| 480 | 484 |
| 481 aura::Window* w2 = root_window()->GetChildById(2); | 485 aura::Window* w2 = root_window()->GetChildById(2); |
| 482 ActivateWindow(w2); | 486 ActivateWindow(w2); |
| 483 EXPECT_EQ(2, GetActiveWindowId()); | 487 EXPECT_EQ(2, GetActiveWindowId()); |
| 484 | 488 |
| 485 ChangeWindowDisposition(w2); | 489 ChangeWindowDisposition(w2); |
| 486 EXPECT_EQ(3, GetActiveWindowId()); | 490 EXPECT_EQ(3, GetActiveWindowId()); |
| 487 } | 491 } |
| 488 virtual void FocusEvents() OVERRIDE { | 492 virtual void FocusEvents() OVERRIDE { |
| 489 aura::Window* w211 = root_window()->GetChildById(211); | 493 aura::Window* w211 = root_window()->GetChildById(211); |
| 490 focus_controller()->FocusWindow(w211); | 494 FocusWindow(w211); |
| 491 | 495 |
| 492 FocusEventsTestHandler handler(root_window()->GetChildById(211)); | 496 FocusEventsTestHandler handler(root_window()->GetChildById(211)); |
| 493 EXPECT_EQ(0, handler.GetCountForEventType( | 497 EXPECT_EQ(0, handler.GetCountForEventType( |
| 494 FocusChangeEvent::focus_changing_event_type())); | 498 FocusChangeEvent::focus_changing_event_type())); |
| 495 EXPECT_EQ(0, handler.GetCountForEventType( | 499 EXPECT_EQ(0, handler.GetCountForEventType( |
| 496 FocusChangeEvent::focus_changed_event_type())); | 500 FocusChangeEvent::focus_changed_event_type())); |
| 497 ChangeWindowDisposition(w211); | 501 ChangeWindowDisposition(w211); |
| 498 EXPECT_EQ(1, handler.GetCountForEventType( | 502 EXPECT_EQ(1, handler.GetCountForEventType( |
| 499 FocusChangeEvent::focus_changing_event_type())); | 503 FocusChangeEvent::focus_changing_event_type())); |
| 500 EXPECT_EQ(1, handler.GetCountForEventType( | 504 EXPECT_EQ(1, handler.GetCountForEventType( |
| (...skipping 12 matching lines...) Expand all Loading... |
| 513 ExpectActivationEvents(&handler_root, 0, 0); | 517 ExpectActivationEvents(&handler_root, 0, 0); |
| 514 ExpectActivationEvents(&handler_2, 0, 0); | 518 ExpectActivationEvents(&handler_2, 0, 0); |
| 515 ExpectActivationEvents(&handler_3, 0, 0); | 519 ExpectActivationEvents(&handler_3, 0, 0); |
| 516 | 520 |
| 517 ChangeWindowDisposition(w2); | 521 ChangeWindowDisposition(w2); |
| 518 ExpectActivationEvents(&handler_root, 1, 1); | 522 ExpectActivationEvents(&handler_root, 1, 1); |
| 519 ExpectActivationEvents(&handler_2, 1, 0); | 523 ExpectActivationEvents(&handler_2, 1, 0); |
| 520 ExpectActivationEvents(&handler_3, 0, 1); | 524 ExpectActivationEvents(&handler_3, 0, 1); |
| 521 } | 525 } |
| 522 virtual void FocusRulesOverride() OVERRIDE { | 526 virtual void FocusRulesOverride() OVERRIDE { |
| 523 EXPECT_EQ(NULL, focused_window()); | 527 EXPECT_EQ(NULL, GetFocusedWindow()); |
| 524 aura::Window* w211 = root_window()->GetChildById(211); | 528 aura::Window* w211 = root_window()->GetChildById(211); |
| 525 focus_controller()->FocusWindow(w211); | 529 FocusWindow(w211); |
| 526 EXPECT_EQ(211, focused_window_id()); | 530 EXPECT_EQ(211, GetFocusedWindowId()); |
| 527 | 531 |
| 528 test_focus_rules()->set_focus_restriction(root_window()->GetChildById(11)); | 532 test_focus_rules()->set_focus_restriction(root_window()->GetChildById(11)); |
| 529 ChangeWindowDisposition(w211); | 533 ChangeWindowDisposition(w211); |
| 530 // Normally, focus would shift to the parent (w21) but the override shifts | 534 // Normally, focus would shift to the parent (w21) but the override shifts |
| 531 // it to 11. | 535 // it to 11. |
| 532 EXPECT_EQ(11, focused_window_id()); | 536 EXPECT_EQ(11, GetFocusedWindowId()); |
| 533 | 537 |
| 534 test_focus_rules()->set_focus_restriction(NULL); | 538 test_focus_rules()->set_focus_restriction(NULL); |
| 535 } | 539 } |
| 536 virtual void ActivationRulesOverride() OVERRIDE { | 540 virtual void ActivationRulesOverride() OVERRIDE { |
| 537 DCHECK(!parent_) << "Activation tests don't support parent changes."; | 541 DCHECK(!parent_) << "Activation tests don't support parent changes."; |
| 538 | 542 |
| 539 aura::Window* w1 = root_window()->GetChildById(1); | 543 aura::Window* w1 = root_window()->GetChildById(1); |
| 540 ActivateWindow(w1); | 544 ActivateWindow(w1); |
| 541 | 545 |
| 542 EXPECT_EQ(1, GetActiveWindowId()); | 546 EXPECT_EQ(1, GetActiveWindowId()); |
| 543 EXPECT_EQ(1, focused_window_id()); | 547 EXPECT_EQ(1, GetFocusedWindowId()); |
| 544 | 548 |
| 545 aura::Window* w3 = root_window()->GetChildById(3); | 549 aura::Window* w3 = root_window()->GetChildById(3); |
| 546 test_focus_rules()->set_focus_restriction(w3); | 550 test_focus_rules()->set_focus_restriction(w3); |
| 547 | 551 |
| 548 // Normally, activation/focus would move to w2, but since we have a focus | 552 // Normally, activation/focus would move to w2, but since we have a focus |
| 549 // restriction, it should move to w3 instead. | 553 // restriction, it should move to w3 instead. |
| 550 ChangeWindowDisposition(w1); | 554 ChangeWindowDisposition(w1); |
| 551 EXPECT_EQ(3, GetActiveWindowId()); | 555 EXPECT_EQ(3, GetActiveWindowId()); |
| 552 EXPECT_EQ(3, focused_window_id()); | 556 EXPECT_EQ(3, GetFocusedWindowId()); |
| 553 | 557 |
| 554 test_focus_rules()->set_focus_restriction(NULL); | 558 test_focus_rules()->set_focus_restriction(NULL); |
| 555 ActivateWindow(root_window()->GetChildById(2)); | 559 ActivateWindow(root_window()->GetChildById(2)); |
| 556 EXPECT_EQ(2, GetActiveWindowId()); | 560 EXPECT_EQ(2, GetActiveWindowId()); |
| 557 EXPECT_EQ(2, focused_window_id()); | 561 EXPECT_EQ(2, GetFocusedWindowId()); |
| 558 } | 562 } |
| 559 | 563 |
| 560 private: | 564 private: |
| 561 // When true, the disposition change occurs to the parent of the window | 565 // When true, the disposition change occurs to the parent of the window |
| 562 // instead of to the window. This verifies that changes occurring in the | 566 // instead of to the window. This verifies that changes occurring in the |
| 563 // hierarchy that contains the window affect the window's focus. | 567 // hierarchy that contains the window affect the window's focus. |
| 564 bool parent_; | 568 bool parent_; |
| 565 | 569 |
| 566 DISALLOW_COPY_AND_ASSIGN(FocusControllerImplicitTestBase); | 570 DISALLOW_COPY_AND_ASSIGN(FocusControllerImplicitTestBase); |
| 567 }; | 571 }; |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 DIRECT_FOCUS_CHANGE_TESTS(ShiftFocusToChildOfInactiveWindow); | 729 DIRECT_FOCUS_CHANGE_TESTS(ShiftFocusToChildOfInactiveWindow); |
| 726 | 730 |
| 727 // - Verifies that FocusRules determine what can be focused. | 731 // - Verifies that FocusRules determine what can be focused. |
| 728 ALL_FOCUS_TESTS(FocusRulesOverride); | 732 ALL_FOCUS_TESTS(FocusRulesOverride); |
| 729 | 733 |
| 730 // - Verifies that FocusRules determine what can be activated. | 734 // - Verifies that FocusRules determine what can be activated. |
| 731 TARGET_FOCUS_TESTS(ActivationRulesOverride); | 735 TARGET_FOCUS_TESTS(ActivationRulesOverride); |
| 732 | 736 |
| 733 } // namespace corewm | 737 } // namespace corewm |
| 734 } // namespace views | 738 } // namespace views |
| OLD | NEW |