| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 6 | 6 |
| 7 #include "apps/app_window.h" | 7 #include "apps/app_window.h" |
| 8 #include "apps/app_window_registry.h" | 8 #include "apps/app_window_registry.h" |
| 9 #include "apps/ui/native_app_window.h" | 9 #include "apps/ui/native_app_window.h" |
| 10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 // Get the index of an item which has the given type. | 265 // Get the index of an item which has the given type. |
| 266 int GetIndexOfShelfItemType(ash::ShelfItemType type) { | 266 int GetIndexOfShelfItemType(ash::ShelfItemType type) { |
| 267 return model_->GetItemIndexForType(type); | 267 return model_->GetItemIndexForType(type); |
| 268 } | 268 } |
| 269 | 269 |
| 270 // Try to rip off |item_index|. | 270 // Try to rip off |item_index|. |
| 271 void RipOffItemIndex(int index, | 271 void RipOffItemIndex(int index, |
| 272 aura::test::EventGenerator* generator, | 272 aura::test::EventGenerator* generator, |
| 273 ash::test::ShelfViewTestAPI* test, | 273 ash::test::ShelfViewTestAPI* test, |
| 274 RipOffCommand command) { | 274 RipOffCommand command) { |
| 275 ash::internal::ShelfButton* button = test->GetButton(index); | 275 ash::ShelfButton* button = test->GetButton(index); |
| 276 gfx::Point start_point = button->GetBoundsInScreen().CenterPoint(); | 276 gfx::Point start_point = button->GetBoundsInScreen().CenterPoint(); |
| 277 gfx::Point rip_off_point(start_point.x(), 0); | 277 gfx::Point rip_off_point(start_point.x(), 0); |
| 278 generator->MoveMouseTo(start_point.x(), start_point.y()); | 278 generator->MoveMouseTo(start_point.x(), start_point.y()); |
| 279 base::MessageLoop::current()->RunUntilIdle(); | 279 base::MessageLoop::current()->RunUntilIdle(); |
| 280 generator->PressLeftButton(); | 280 generator->PressLeftButton(); |
| 281 base::MessageLoop::current()->RunUntilIdle(); | 281 base::MessageLoop::current()->RunUntilIdle(); |
| 282 generator->MoveMouseTo(rip_off_point.x(), rip_off_point.y()); | 282 generator->MoveMouseTo(rip_off_point.x(), rip_off_point.y()); |
| 283 base::MessageLoop::current()->RunUntilIdle(); | 283 base::MessageLoop::current()->RunUntilIdle(); |
| 284 test->RunMessageLoopUntilAnimationsDone(); | 284 test->RunMessageLoopUntilAnimationsDone(); |
| 285 if (command == RIP_OFF_ITEM_AND_RETURN) { | 285 if (command == RIP_OFF_ITEM_AND_RETURN) { |
| (...skipping 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1767 // Test #1: Ripping out the browser item should not change anything. | 1767 // Test #1: Ripping out the browser item should not change anything. |
| 1768 int browser_index = GetIndexOfShelfItemType(ash::TYPE_BROWSER_SHORTCUT); | 1768 int browser_index = GetIndexOfShelfItemType(ash::TYPE_BROWSER_SHORTCUT); |
| 1769 EXPECT_LE(0, browser_index); | 1769 EXPECT_LE(0, browser_index); |
| 1770 RipOffItemIndex(browser_index, &generator, &test, RIP_OFF_ITEM); | 1770 RipOffItemIndex(browser_index, &generator, &test, RIP_OFF_ITEM); |
| 1771 // => It should not have been removed and the location should be unchanged. | 1771 // => It should not have been removed and the location should be unchanged. |
| 1772 EXPECT_EQ(3, model_->item_count()); | 1772 EXPECT_EQ(3, model_->item_count()); |
| 1773 EXPECT_EQ(browser_index, | 1773 EXPECT_EQ(browser_index, |
| 1774 GetIndexOfShelfItemType(ash::TYPE_BROWSER_SHORTCUT)); | 1774 GetIndexOfShelfItemType(ash::TYPE_BROWSER_SHORTCUT)); |
| 1775 // Make sure that the hide state has been unset after the snap back animation | 1775 // Make sure that the hide state has been unset after the snap back animation |
| 1776 // finished. | 1776 // finished. |
| 1777 ash::internal::ShelfButton* button = test.GetButton(browser_index); | 1777 ash::ShelfButton* button = test.GetButton(browser_index); |
| 1778 EXPECT_FALSE(button->state() & ash::internal::ShelfButton::STATE_HIDDEN); | 1778 EXPECT_FALSE(button->state() & ash::ShelfButton::STATE_HIDDEN); |
| 1779 | 1779 |
| 1780 // Test #2: Ripping out the application and canceling the operation should | 1780 // Test #2: Ripping out the application and canceling the operation should |
| 1781 // not change anything. | 1781 // not change anything. |
| 1782 int app_index = GetIndexOfShelfItemType(ash::TYPE_APP_SHORTCUT); | 1782 int app_index = GetIndexOfShelfItemType(ash::TYPE_APP_SHORTCUT); |
| 1783 EXPECT_LE(0, app_index); | 1783 EXPECT_LE(0, app_index); |
| 1784 RipOffItemIndex(app_index, &generator, &test, RIP_OFF_ITEM_AND_CANCEL); | 1784 RipOffItemIndex(app_index, &generator, &test, RIP_OFF_ITEM_AND_CANCEL); |
| 1785 // => It should not have been removed and the location should be unchanged. | 1785 // => It should not have been removed and the location should be unchanged. |
| 1786 ASSERT_EQ(3, model_->item_count()); | 1786 ASSERT_EQ(3, model_->item_count()); |
| 1787 EXPECT_EQ(app_index, GetIndexOfShelfItemType(ash::TYPE_APP_SHORTCUT)); | 1787 EXPECT_EQ(app_index, GetIndexOfShelfItemType(ash::TYPE_APP_SHORTCUT)); |
| 1788 | 1788 |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2023 GURL("http://www.foo.com/bar.html")); | 2023 GURL("http://www.foo.com/bar.html")); |
| 2024 // Make sure the navigation was entirely performed. | 2024 // Make sure the navigation was entirely performed. |
| 2025 base::MessageLoop::current()->RunUntilIdle(); | 2025 base::MessageLoop::current()->RunUntilIdle(); |
| 2026 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(id)->status); | 2026 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(id)->status); |
| 2027 app_browser->tab_strip_model()->CloseWebContentsAt(0, | 2027 app_browser->tab_strip_model()->CloseWebContentsAt(0, |
| 2028 TabStripModel::CLOSE_NONE); | 2028 TabStripModel::CLOSE_NONE); |
| 2029 // Make sure that the app is really gone. | 2029 // Make sure that the app is really gone. |
| 2030 base::MessageLoop::current()->RunUntilIdle(); | 2030 base::MessageLoop::current()->RunUntilIdle(); |
| 2031 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(id)->status); | 2031 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(id)->status); |
| 2032 } | 2032 } |
| OLD | NEW |