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 "ash/launcher/launcher_view.h" | 5 #include "ash/launcher/launcher_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/launcher/launcher.h" | 10 #include "ash/launcher/launcher.h" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 } | 160 } |
161 virtual ash::LauncherID GetIDByWindow(aura::Window* window) OVERRIDE { | 161 virtual ash::LauncherID GetIDByWindow(aura::Window* window) OVERRIDE { |
162 NOTREACHED(); | 162 NOTREACHED(); |
163 return -1; | 163 return -1; |
164 } | 164 } |
165 virtual bool IsDraggable(const ash::LauncherItem& item) OVERRIDE { | 165 virtual bool IsDraggable(const ash::LauncherItem& item) OVERRIDE { |
166 return true; | 166 return true; |
167 } | 167 } |
168 }; | 168 }; |
169 | 169 |
170 class LauncherViewTest : public aura::test::AuraTestBase { | 170 class LauncherViewTest : public AshTestBase { |
171 public: | 171 public: |
172 LauncherViewTest() {} | 172 LauncherViewTest() {} |
173 virtual ~LauncherViewTest() {} | 173 virtual ~LauncherViewTest() {} |
174 | 174 |
175 virtual void SetUp() OVERRIDE { | 175 virtual void SetUp() OVERRIDE { |
176 aura::test::AuraTestBase::SetUp(); | 176 AshTestBase::SetUp(); |
177 | 177 |
178 model_.reset(new LauncherModel); | 178 model_.reset(new LauncherModel); |
179 | 179 |
180 launcher_view_.reset(new internal::LauncherView( | 180 launcher_view_.reset(new internal::LauncherView( |
181 model_.get(), &delegate_, NULL)); | 181 model_.get(), &delegate_, NULL)); |
182 launcher_view_->Init(); | 182 launcher_view_->Init(); |
183 // The bounds should be big enough for 4 buttons + overflow chevron. | 183 // The bounds should be big enough for 4 buttons + overflow chevron. |
184 launcher_view_->SetBounds(0, 0, 500, 50); | 184 launcher_view_->SetBounds(0, 0, 500, 50); |
185 | 185 |
186 test_api_.reset(new LauncherViewTestAPI(launcher_view_.get())); | 186 test_api_.reset(new LauncherViewTestAPI(launcher_view_.get())); |
187 test_api_->SetAnimationDuration(1); // Speeds up animation for test. | 187 test_api_->SetAnimationDuration(1); // Speeds up animation for test. |
188 } | 188 } |
189 | 189 |
| 190 virtual void TearDown() OVERRIDE { |
| 191 launcher_view_.reset(); |
| 192 AshTestBase::TearDown(); |
| 193 } |
| 194 |
190 protected: | 195 protected: |
191 LauncherID AddAppShortcut() { | 196 LauncherID AddAppShortcut() { |
192 LauncherItem item; | 197 LauncherItem item; |
193 item.type = TYPE_APP_SHORTCUT; | 198 item.type = TYPE_APP_SHORTCUT; |
194 item.status = STATUS_CLOSED; | 199 item.status = STATUS_CLOSED; |
195 | 200 |
196 LauncherID id = model_->next_id(); | 201 LauncherID id = model_->next_id(); |
197 model_->Add(item); | 202 model_->Add(item); |
198 test_api_->RunMessageLoopUntilAnimationsDone(); | 203 test_api_->RunMessageLoopUntilAnimationsDone(); |
199 return id; | 204 return id; |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 EXPECT_TRUE(launcher_view_->ShouldHideTooltip( | 649 EXPECT_TRUE(launcher_view_->ShouldHideTooltip( |
645 gfx::Point(all_area.right(), all_area.y()))); | 650 gfx::Point(all_area.right(), all_area.y()))); |
646 EXPECT_TRUE(launcher_view_->ShouldHideTooltip( | 651 EXPECT_TRUE(launcher_view_->ShouldHideTooltip( |
647 gfx::Point(all_area.x() - 1, all_area.y()))); | 652 gfx::Point(all_area.x() - 1, all_area.y()))); |
648 EXPECT_TRUE(launcher_view_->ShouldHideTooltip( | 653 EXPECT_TRUE(launcher_view_->ShouldHideTooltip( |
649 gfx::Point(all_area.x(), all_area.y() - 1))); | 654 gfx::Point(all_area.x(), all_area.y() - 1))); |
650 EXPECT_TRUE(launcher_view_->ShouldHideTooltip( | 655 EXPECT_TRUE(launcher_view_->ShouldHideTooltip( |
651 gfx::Point(all_area.x(), all_area.bottom()))); | 656 gfx::Point(all_area.x(), all_area.bottom()))); |
652 } | 657 } |
653 | 658 |
| 659 TEST_F(LauncherViewTest, ShouldHideTooltipWithAppListWindowTest) { |
| 660 Shell::GetInstance()->ToggleAppList(); |
| 661 ASSERT_TRUE(Shell::GetInstance()->GetAppListWindow()); |
| 662 |
| 663 // The tooltip shouldn't hide if the mouse is on normal buttons. |
| 664 for (int i = 0; i < test_api_->GetButtonCount() - 1; i++) { |
| 665 internal::LauncherButton* button = test_api_->GetButton(i); |
| 666 EXPECT_FALSE(launcher_view_->ShouldHideTooltip( |
| 667 button->GetMirroredBounds().CenterPoint())) |
| 668 << "LauncherView tries to hide on button " << i; |
| 669 } |
| 670 |
| 671 // The tooltip should hide on the app-list button. |
| 672 views::View* app_list_button = launcher_view_->GetAppListButtonView(); |
| 673 EXPECT_TRUE(launcher_view_->ShouldHideTooltip( |
| 674 app_list_button->GetMirroredBounds().CenterPoint())); |
| 675 } |
| 676 |
654 // Resizing launcher view while an add animation without fade-in is running, | 677 // Resizing launcher view while an add animation without fade-in is running, |
655 // which happens when overflow happens. App list button should end up in its | 678 // which happens when overflow happens. App list button should end up in its |
656 // new ideal bounds. | 679 // new ideal bounds. |
657 TEST_F(LauncherViewTest, ResizeDuringOverflowAddAnimation) { | 680 TEST_F(LauncherViewTest, ResizeDuringOverflowAddAnimation) { |
658 // All buttons should be visible. | 681 // All buttons should be visible. |
659 ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1, | 682 ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1, |
660 test_api_->GetButtonCount()); | 683 test_api_->GetButtonCount()); |
661 | 684 |
662 // Add buttons until overflow. Let the non-overflow add animations finish but | 685 // Add buttons until overflow. Let the non-overflow add animations finish but |
663 // leave the last running. | 686 // leave the last running. |
(...skipping 16 matching lines...) Expand all Loading... |
680 const int app_list_button_index = test_api_->GetButtonCount() - 1; | 703 const int app_list_button_index = test_api_->GetButtonCount() - 1; |
681 const gfx::Rect& app_list_ideal_bounds = | 704 const gfx::Rect& app_list_ideal_bounds = |
682 test_api_->GetIdealBoundsByIndex(app_list_button_index); | 705 test_api_->GetIdealBoundsByIndex(app_list_button_index); |
683 const gfx::Rect& app_list_bounds = | 706 const gfx::Rect& app_list_bounds = |
684 test_api_->GetBoundsByIndex(app_list_button_index); | 707 test_api_->GetBoundsByIndex(app_list_button_index); |
685 EXPECT_EQ(app_list_bounds, app_list_ideal_bounds); | 708 EXPECT_EQ(app_list_bounds, app_list_ideal_bounds); |
686 } | 709 } |
687 | 710 |
688 } // namespace test | 711 } // namespace test |
689 } // namespace ash | 712 } // namespace ash |
OLD | NEW |