Chromium Code Reviews| 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 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 715 EXPECT_EQ(original_bounds, w->bounds()); | 715 EXPECT_EQ(original_bounds, w->bounds()); |
| 716 | 716 |
| 717 // Fullscreen | 717 // Fullscreen |
| 718 w->Fullscreen(); | 718 w->Fullscreen(); |
| 719 EXPECT_EQ(ui::SHOW_STATE_FULLSCREEN, w->show_state()); | 719 EXPECT_EQ(ui::SHOW_STATE_FULLSCREEN, w->show_state()); |
| 720 EXPECT_EQ(desktop_bounds, w->bounds()); | 720 EXPECT_EQ(desktop_bounds, w->bounds()); |
| 721 w->Restore(); | 721 w->Restore(); |
| 722 EXPECT_EQ(ui::SHOW_STATE_NORMAL, w->show_state()); | 722 EXPECT_EQ(ui::SHOW_STATE_NORMAL, w->show_state()); |
| 723 EXPECT_EQ(original_bounds, w->bounds()); | 723 EXPECT_EQ(original_bounds, w->bounds()); |
| 724 | 724 |
| 725 // Fullscreen twice | 725 // Fullscreen twice |
|
Ben Goodger (Google)
2011/10/14 15:40:05
This comment just says what the code does, not wha
oshima
2011/10/15 02:10:50
Done.
| |
| 726 w->Fullscreen(); | 726 w->Fullscreen(); |
| 727 w->Fullscreen(); | 727 w->Fullscreen(); |
| 728 EXPECT_EQ(desktop_bounds, w->bounds()); | 728 EXPECT_EQ(desktop_bounds, w->bounds()); |
| 729 w->Restore(); | 729 w->Restore(); |
| 730 EXPECT_EQ(ui::SHOW_STATE_NORMAL, w->show_state()); | 730 EXPECT_EQ(ui::SHOW_STATE_NORMAL, w->show_state()); |
| 731 EXPECT_EQ(original_bounds, w->bounds()); | 731 EXPECT_EQ(original_bounds, w->bounds()); |
| 732 | |
| 733 // SetBounds in fullscreen mode | |
|
Ben Goodger (Google)
2011/10/14 15:40:05
Same here.
// Calling SetBounds() while in full s
oshima
2011/10/15 02:10:50
Done.
| |
| 734 gfx::Rect new_bounds(50, 50, 50, 50); | |
| 735 w->Fullscreen(); | |
| 736 w->SetBounds(new_bounds); | |
| 737 EXPECT_EQ(desktop_bounds, w->bounds()); | |
| 738 w->Restore(); | |
| 739 EXPECT_EQ(new_bounds, w->bounds()); | |
| 732 } | 740 } |
| 733 | 741 |
| 734 TEST_F(WindowTest, Maximized) { | 742 TEST_F(WindowTest, Maximized) { |
| 735 gfx::Rect original_bounds = gfx::Rect(100, 100, 100, 100); | 743 gfx::Rect original_bounds = gfx::Rect(100, 100, 100, 100); |
| 736 gfx::Rect desktop_bounds(Desktop::GetInstance()->GetSize()); | 744 gfx::Rect desktop_bounds(Desktop::GetInstance()->GetSize()); |
| 737 scoped_ptr<Window> w(CreateTestWindowWithDelegate( | 745 scoped_ptr<Window> w(CreateTestWindowWithDelegate( |
| 738 NULL, 1, original_bounds, NULL)); | 746 NULL, 1, original_bounds, NULL)); |
| 739 EXPECT_EQ(original_bounds, w->bounds()); | 747 EXPECT_EQ(original_bounds, w->bounds()); |
| 740 | 748 |
| 741 // Maximized | 749 // Maximized |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 763 EXPECT_EQ(max_bounds, w->bounds()); | 771 EXPECT_EQ(max_bounds, w->bounds()); |
| 764 w->Fullscreen(); | 772 w->Fullscreen(); |
| 765 EXPECT_EQ(ui::SHOW_STATE_FULLSCREEN, w->show_state()); | 773 EXPECT_EQ(ui::SHOW_STATE_FULLSCREEN, w->show_state()); |
| 766 EXPECT_EQ(desktop_bounds, w->bounds()); | 774 EXPECT_EQ(desktop_bounds, w->bounds()); |
| 767 w->Maximize(); | 775 w->Maximize(); |
| 768 EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, w->show_state()); | 776 EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, w->show_state()); |
| 769 EXPECT_EQ(max_bounds, w->bounds()); | 777 EXPECT_EQ(max_bounds, w->bounds()); |
| 770 w->Restore(); | 778 w->Restore(); |
| 771 EXPECT_EQ(ui::SHOW_STATE_NORMAL, w->show_state()); | 779 EXPECT_EQ(ui::SHOW_STATE_NORMAL, w->show_state()); |
| 772 EXPECT_EQ(original_bounds, w->bounds()); | 780 EXPECT_EQ(original_bounds, w->bounds()); |
| 781 | |
| 782 // SetBounds in maximized mode | |
|
Ben Goodger (Google)
2011/10/14 15:40:05
Same as above.
oshima
2011/10/15 02:10:50
Done.
| |
| 783 gfx::Rect new_bounds(50, 50, 50, 50); | |
| 784 w->Maximize(); | |
| 785 w->SetBounds(new_bounds); | |
| 786 EXPECT_EQ(max_bounds, w->bounds()); | |
| 787 w->Restore(); | |
| 788 EXPECT_EQ(new_bounds, w->bounds()); | |
| 773 } | 789 } |
| 774 | 790 |
| 775 // Various assertions for activating/deactivating. | 791 // Various assertions for activating/deactivating. |
| 776 TEST_F(WindowTest, Deactivate) { | 792 TEST_F(WindowTest, Deactivate) { |
| 777 TestWindowDelegate d1; | 793 TestWindowDelegate d1; |
| 778 TestWindowDelegate d2; | 794 TestWindowDelegate d2; |
| 779 scoped_ptr<Window> w1( | 795 scoped_ptr<Window> w1( |
| 780 CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(), NULL)); | 796 CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(), NULL)); |
| 781 scoped_ptr<Window> w2( | 797 scoped_ptr<Window> w2( |
| 782 CreateTestWindowWithDelegate(&d2, 2, gfx::Rect(), NULL)); | 798 CreateTestWindowWithDelegate(&d2, 2, gfx::Rect(), NULL)); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 797 EXPECT_EQ(w1.get(), parent->children()[1]); | 813 EXPECT_EQ(w1.get(), parent->children()[1]); |
| 798 | 814 |
| 799 // Deactivate w1 and make sure w2 becomes active and frontmost. | 815 // Deactivate w1 and make sure w2 becomes active and frontmost. |
| 800 w1->Deactivate(); | 816 w1->Deactivate(); |
| 801 EXPECT_FALSE(w1->IsActive()); | 817 EXPECT_FALSE(w1->IsActive()); |
| 802 EXPECT_TRUE(w2->IsActive()); | 818 EXPECT_TRUE(w2->IsActive()); |
| 803 EXPECT_EQ(w2.get(), parent->children()[1]); | 819 EXPECT_EQ(w2.get(), parent->children()[1]); |
| 804 } | 820 } |
| 805 | 821 |
| 806 class WindowObserverTest : public WindowTest, | 822 class WindowObserverTest : public WindowTest, |
| 807 public WindowObserver { | 823 public WindowObserver { |
| 808 public: | 824 public: |
| 809 WindowObserverTest() : added_count_(0), removed_count_(0) {} | 825 WindowObserverTest() : added_count_(0), removed_count_(0) {} |
| 810 | 826 |
| 811 virtual ~WindowObserverTest() {} | 827 virtual ~WindowObserverTest() {} |
| 812 | 828 |
| 813 // Returns a description of the WindowObserver methods that have been invoked. | 829 // Returns a description of the WindowObserver methods that have been invoked. |
| 814 std::string WindowObserverCountStateAndClear() { | 830 std::string WindowObserverCountStateAndClear() { |
| 815 std::string result( | 831 std::string result( |
| 816 base::StringPrintf("added=%d removed=%d", | 832 base::StringPrintf("added=%d removed=%d", |
| 817 added_count_, removed_count_)); | 833 added_count_, removed_count_)); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 904 | 920 |
| 905 w3->Activate(); | 921 w3->Activate(); |
| 906 EXPECT_EQ(w2.get(), active()); | 922 EXPECT_EQ(w2.get(), active()); |
| 907 | 923 |
| 908 w1->Activate(); | 924 w1->Activate(); |
| 909 EXPECT_EQ(w1.get(), active()); | 925 EXPECT_EQ(w1.get(), active()); |
| 910 } | 926 } |
| 911 | 927 |
| 912 } // namespace test | 928 } // namespace test |
| 913 } // namespace aura | 929 } // namespace aura |
| OLD | NEW |