OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/aura/window.h" | 5 #include "ui/aura/window.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 | 497 |
498 // Verifies that when WindowDelegate::OnLostActive is invoked the window is not | 498 // Verifies that when WindowDelegate::OnLostActive is invoked the window is not |
499 // active. | 499 // active. |
500 TEST_F(WindowTest, NotActiveInLostActive) { | 500 TEST_F(WindowTest, NotActiveInLostActive) { |
501 Desktop* desktop = Desktop::GetInstance(); | 501 Desktop* desktop = Desktop::GetInstance(); |
502 | 502 |
503 ActiveWindowDelegate d1; | 503 ActiveWindowDelegate d1; |
504 scoped_ptr<Window> w1( | 504 scoped_ptr<Window> w1( |
505 CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(10, 10, 50, 50), NULL)); | 505 CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(10, 10, 50, 50), NULL)); |
506 d1.set_window(w1.get()); | 506 d1.set_window(w1.get()); |
| 507 scoped_ptr<Window> w2( |
| 508 CreateTestWindowWithDelegate(NULL, 1, gfx::Rect(10, 10, 50, 50), NULL)); |
507 | 509 |
508 // Activate w1. | 510 // Activate w1. |
509 desktop->SetActiveWindow(w1.get(), NULL); | 511 desktop->SetActiveWindow(w1.get(), NULL); |
510 EXPECT_EQ(w1.get(), desktop->active_window()); | 512 EXPECT_EQ(w1.get(), desktop->active_window()); |
511 | 513 |
512 // Should not have gotten a OnLostActive yet. | 514 // Should not have gotten a OnLostActive yet. |
513 EXPECT_EQ(0, d1.hit_count()); | 515 EXPECT_EQ(0, d1.hit_count()); |
514 | 516 |
515 // Change the active window to NULL. | 517 // SetActiveWindow(NULL) should not change the active window. |
516 desktop->SetActiveWindow(NULL, NULL); | 518 desktop->SetActiveWindow(NULL, NULL); |
517 EXPECT_TRUE(desktop->active_window() == NULL); | 519 EXPECT_TRUE(desktop->active_window() == w1.get()); |
| 520 |
| 521 // Now activate another window. |
| 522 desktop->SetActiveWindow(w2.get(), NULL); |
518 | 523 |
519 // Should have gotten OnLostActive and w1 should not have been active at that | 524 // Should have gotten OnLostActive and w1 should not have been active at that |
520 // time. | 525 // time. |
521 EXPECT_EQ(1, d1.hit_count()); | 526 EXPECT_EQ(1, d1.hit_count()); |
522 EXPECT_FALSE(d1.was_active()); | 527 EXPECT_FALSE(d1.was_active()); |
523 } | 528 } |
524 | 529 |
525 // Creates a window with a delegate (w111) that can handle events at a lower | 530 // Creates a window with a delegate (w111) that can handle events at a lower |
526 // z-index than a window without a delegate (w12). w12 is sized to fill the | 531 // z-index than a window without a delegate (w12). w12 is sized to fill the |
527 // entire bounds of the container. This test verifies that | 532 // entire bounds of the container. This test verifies that |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1051 | 1056 |
1052 w3->Activate(); | 1057 w3->Activate(); |
1053 EXPECT_EQ(w2.get(), active()); | 1058 EXPECT_EQ(w2.get(), active()); |
1054 | 1059 |
1055 w1->Activate(); | 1060 w1->Activate(); |
1056 EXPECT_EQ(w1.get(), active()); | 1061 EXPECT_EQ(w1.get(), active()); |
1057 } | 1062 } |
1058 | 1063 |
1059 } // namespace test | 1064 } // namespace test |
1060 } // namespace aura | 1065 } // namespace aura |
OLD | NEW |