| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "ui/aura/desktop.h" | 8 #include "ui/aura/desktop.h" |
| 9 #include "ui/aura/desktop_observer.h" |
| 9 #include "ui/aura/event.h" | 10 #include "ui/aura/event.h" |
| 10 #include "ui/aura/focus_manager.h" | 11 #include "ui/aura/focus_manager.h" |
| 11 #include "ui/aura/hit_test.h" | 12 #include "ui/aura/hit_test.h" |
| 12 #include "ui/aura/root_window.h" | 13 #include "ui/aura/root_window.h" |
| 13 #include "ui/aura/test/aura_test_base.h" | 14 #include "ui/aura/test/aura_test_base.h" |
| 14 #include "ui/aura/test/test_desktop_delegate.h" | 15 #include "ui/aura/test/test_desktop_delegate.h" |
| 15 #include "ui/aura/test/test_window_delegate.h" | 16 #include "ui/aura/test/test_window_delegate.h" |
| 16 #include "ui/aura/window_delegate.h" | 17 #include "ui/aura/window_delegate.h" |
| 17 #include "ui/gfx/canvas_skia.h" | 18 #include "ui/gfx/canvas_skia.h" |
| 18 #include "ui/gfx/compositor/layer.h" | 19 #include "ui/gfx/compositor/layer.h" |
| (...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 753 EXPECT_FALSE(w2->IsActive()); | 754 EXPECT_FALSE(w2->IsActive()); |
| 754 EXPECT_EQ(w1.get(), parent->children()[1]); | 755 EXPECT_EQ(w1.get(), parent->children()[1]); |
| 755 | 756 |
| 756 // Deactivate w1 and make sure w2 becomes active and frontmost. | 757 // Deactivate w1 and make sure w2 becomes active and frontmost. |
| 757 w1->Deactivate(); | 758 w1->Deactivate(); |
| 758 EXPECT_FALSE(w1->IsActive()); | 759 EXPECT_FALSE(w1->IsActive()); |
| 759 EXPECT_TRUE(w2->IsActive()); | 760 EXPECT_TRUE(w2->IsActive()); |
| 760 EXPECT_EQ(w2.get(), parent->children()[1]); | 761 EXPECT_EQ(w2.get(), parent->children()[1]); |
| 761 } | 762 } |
| 762 | 763 |
| 764 class ObserverTest : public WindowTest, |
| 765 public DesktopObserver { |
| 766 public: |
| 767 ObserverTest() |
| 768 : active_(NULL) { |
| 769 } |
| 770 |
| 771 virtual ~ObserverTest() {} |
| 772 |
| 773 Window* active() const { return active_; } |
| 774 |
| 775 void Reset() { |
| 776 active_ = NULL; |
| 777 } |
| 778 |
| 779 private: |
| 780 virtual void SetUp() OVERRIDE { |
| 781 WindowTest::SetUp(); |
| 782 Desktop::GetInstance()->AddObserver(this); |
| 783 } |
| 784 |
| 785 virtual void TearDown() OVERRIDE { |
| 786 Desktop::GetInstance()->RemoveObserver(this); |
| 787 WindowTest::TearDown(); |
| 788 } |
| 789 |
| 790 virtual void OnActiveWindowChanged(Window* active) OVERRIDE { |
| 791 active_ = active; |
| 792 } |
| 793 |
| 794 Window* active_; |
| 795 |
| 796 DISALLOW_COPY_AND_ASSIGN(ObserverTest); |
| 797 }; |
| 798 |
| 799 TEST_F(ObserverTest, WindowActivationObserve) { |
| 800 scoped_ptr<Window> w1(CreateTestWindowWithId(1, NULL)); |
| 801 scoped_ptr<Window> w2(CreateTestWindowWithId(2, NULL)); |
| 802 scoped_ptr<Window> w3(CreateTestWindowWithId(3, w1.get())); |
| 803 |
| 804 EXPECT_EQ(NULL, active()); |
| 805 |
| 806 w2->Activate(); |
| 807 EXPECT_EQ(w2.get(), active()); |
| 808 |
| 809 w3->Activate(); |
| 810 EXPECT_EQ(w2.get(), active()); |
| 811 |
| 812 w1->Activate(); |
| 813 EXPECT_EQ(w1.get(), active()); |
| 814 } |
| 815 |
| 763 } // namespace test | 816 } // namespace test |
| 764 } // namespace aura | 817 } // namespace aura |
| OLD | NEW |