| 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 "chrome/browser/ui/ash/launcher/browser_launcher_item_controller.h" | 5 #include "chrome/browser/ui/ash/launcher/browser_launcher_item_controller.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
| 11 #include "ash/launcher/launcher_model.h" | 11 #include "ash/launcher/launcher_model.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "chrome/browser/favicon/favicon_tab_helper.h" | 14 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 15 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 15 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 16 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" | 16 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" |
| 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 18 #include "chrome/browser/ui/tabs/test_tab_strip_model_delegate.h" | 18 #include "chrome/browser/ui/tabs/test_tab_strip_model_delegate.h" |
| 19 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 19 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 20 #include "chrome/test/base/testing_profile.h" | 20 #include "chrome/test/base/testing_profile.h" |
| 21 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
| 22 #include "content/public/test/test_browser_thread.h" | |
| 23 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 24 #include "third_party/skia/include/core/SkBitmap.h" | 23 #include "third_party/skia/include/core/SkBitmap.h" |
| 25 #include "ui/aura/client/activation_change_observer.h" | 24 #include "ui/aura/client/activation_change_observer.h" |
| 26 #include "ui/aura/client/activation_delegate.h" | 25 #include "ui/aura/client/activation_delegate.h" |
| 27 #include "ui/aura/client/aura_constants.h" | 26 #include "ui/aura/client/aura_constants.h" |
| 28 #include "ui/aura/root_window.h" | 27 #include "ui/aura/root_window.h" |
| 29 #include "ui/aura/test/test_activation_client.h" | 28 #include "ui/aura/test/test_activation_client.h" |
| 30 #include "ui/aura/test/test_window_delegate.h" | 29 #include "ui/aura/test/test_window_delegate.h" |
| 31 #include "ui/aura/window.h" | 30 #include "ui/aura/window.h" |
| 32 #include "ui/aura/window_delegate.h" | 31 #include "ui/aura/window_delegate.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 125 |
| 127 } // namespace | 126 } // namespace |
| 128 | 127 |
| 129 // TODO(skuhne): Several of these unit tests need to be moved into a new home | 128 // TODO(skuhne): Several of these unit tests need to be moved into a new home |
| 130 // when the old launcher & the browser launcher item controller are removed | 129 // when the old launcher & the browser launcher item controller are removed |
| 131 // (several of these tests are not testing the BrowserLauncherItemController - | 130 // (several of these tests are not testing the BrowserLauncherItemController - |
| 132 // but the LauncherController framework). | 131 // but the LauncherController framework). |
| 133 class LauncherItemControllerPerAppTest | 132 class LauncherItemControllerPerAppTest |
| 134 : public ChromeRenderViewHostTestHarness { | 133 : public ChromeRenderViewHostTestHarness { |
| 135 public: | 134 public: |
| 136 LauncherItemControllerPerAppTest() | |
| 137 : browser_thread_(content::BrowserThread::UI, &message_loop_) { | |
| 138 } | |
| 139 | |
| 140 virtual void SetUp() OVERRIDE { | 135 virtual void SetUp() OVERRIDE { |
| 141 ChromeRenderViewHostTestHarness::SetUp(); | 136 ChromeRenderViewHostTestHarness::SetUp(); |
| 142 | 137 |
| 143 activation_client_.reset( | 138 activation_client_.reset( |
| 144 new aura::test::TestActivationClient(root_window())); | 139 new aura::test::TestActivationClient(root_window())); |
| 145 launcher_model_.reset(new ash::LauncherModel); | 140 launcher_model_.reset(new ash::LauncherModel); |
| 146 launcher_delegate_.reset( | 141 launcher_delegate_.reset( |
| 147 ChromeLauncherController::CreateInstance(profile(), | 142 ChromeLauncherController::CreateInstance(profile(), |
| 148 launcher_model_.get())); | 143 launcher_model_.get())); |
| 149 app_tab_helper_ = new AppTabHelperImpl; | 144 app_tab_helper_ = new AppTabHelperImpl; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 } | 229 } |
| 235 | 230 |
| 236 scoped_ptr<ash::LauncherModel> launcher_model_; | 231 scoped_ptr<ash::LauncherModel> launcher_model_; |
| 237 scoped_ptr<ChromeLauncherController> launcher_delegate_; | 232 scoped_ptr<ChromeLauncherController> launcher_delegate_; |
| 238 | 233 |
| 239 // Owned by BrowserLauncherItemController. | 234 // Owned by BrowserLauncherItemController. |
| 240 AppTabHelperImpl* app_tab_helper_; | 235 AppTabHelperImpl* app_tab_helper_; |
| 241 AppIconLoaderImpl* app_icon_loader_; | 236 AppIconLoaderImpl* app_icon_loader_; |
| 242 | 237 |
| 243 scoped_ptr<aura::test::TestActivationClient> activation_client_; | 238 scoped_ptr<aura::test::TestActivationClient> activation_client_; |
| 244 | |
| 245 private: | |
| 246 content::TestBrowserThread browser_thread_; | |
| 247 | |
| 248 DISALLOW_COPY_AND_ASSIGN(LauncherItemControllerPerAppTest); | |
| 249 }; | 239 }; |
| 250 | 240 |
| 251 // Verify that the launcher item positions are persisted and restored. | 241 // Verify that the launcher item positions are persisted and restored. |
| 252 TEST_F(LauncherItemControllerPerAppTest, PersistLauncherItemPositions) { | 242 TEST_F(LauncherItemControllerPerAppTest, PersistLauncherItemPositions) { |
| 253 EXPECT_EQ(ash::TYPE_BROWSER_SHORTCUT, | 243 EXPECT_EQ(ash::TYPE_BROWSER_SHORTCUT, |
| 254 launcher_model_->items()[0].type); | 244 launcher_model_->items()[0].type); |
| 255 EXPECT_EQ(ash::TYPE_APP_LIST, | 245 EXPECT_EQ(ash::TYPE_APP_LIST, |
| 256 launcher_model_->items()[1].type); | 246 launcher_model_->items()[1].type); |
| 257 scoped_ptr<content::WebContents> tab1(CreateTestWebContents()); | 247 scoped_ptr<content::WebContents> tab1(CreateTestWebContents()); |
| 258 scoped_ptr<content::WebContents> tab2(CreateTestWebContents()); | 248 scoped_ptr<content::WebContents> tab2(CreateTestWebContents()); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 virtual void SetUp() OVERRIDE { | 301 virtual void SetUp() OVERRIDE { |
| 312 CommandLine::ForCurrentProcess()->AppendSwitch( | 302 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 313 ash::switches::kAshDisablePerAppLauncher); | 303 ash::switches::kAshDisablePerAppLauncher); |
| 314 | 304 |
| 315 LauncherItemControllerPerAppTest::SetUp(); | 305 LauncherItemControllerPerAppTest::SetUp(); |
| 316 } | 306 } |
| 317 | 307 |
| 318 virtual void TearDown() OVERRIDE { | 308 virtual void TearDown() OVERRIDE { |
| 319 LauncherItemControllerPerAppTest::TearDown(); | 309 LauncherItemControllerPerAppTest::TearDown(); |
| 320 } | 310 } |
| 321 | |
| 322 DISALLOW_COPY_AND_ASSIGN(BrowserLauncherItemControllerTest); | |
| 323 }; | 311 }; |
| 324 | 312 |
| 325 // Verifies a new launcher item is added for TYPE_TABBED. | 313 // Verifies a new launcher item is added for TYPE_TABBED. |
| 326 TEST_F(BrowserLauncherItemControllerTest, TabbedSetup) { | 314 TEST_F(BrowserLauncherItemControllerTest, TabbedSetup) { |
| 327 size_t initial_size = launcher_model_->items().size(); | 315 size_t initial_size = launcher_model_->items().size(); |
| 328 { | 316 { |
| 329 scoped_ptr<content::WebContents> web_contents(CreateTestWebContents()); | 317 scoped_ptr<content::WebContents> web_contents(CreateTestWebContents()); |
| 330 State state(this, std::string(), | 318 State state(this, std::string(), |
| 331 BrowserLauncherItemController::TYPE_TABBED); | 319 BrowserLauncherItemController::TYPE_TABBED); |
| 332 | 320 |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 EXPECT_EQ(ash::STATUS_RUNNING, app_state.GetUpdaterItem().status); | 532 EXPECT_EQ(ash::STATUS_RUNNING, app_state.GetUpdaterItem().status); |
| 545 | 533 |
| 546 // App window should go to attention state. | 534 // App window should go to attention state. |
| 547 app_state.window.SetProperty(aura::client::kDrawAttentionKey, true); | 535 app_state.window.SetProperty(aura::client::kDrawAttentionKey, true); |
| 548 EXPECT_EQ(ash::STATUS_ATTENTION, app_state.GetUpdaterItem().status); | 536 EXPECT_EQ(ash::STATUS_ATTENTION, app_state.GetUpdaterItem().status); |
| 549 | 537 |
| 550 // Activating app window should clear attention state. | 538 // Activating app window should clear attention state. |
| 551 activation_client_->ActivateWindow(&app_state.window); | 539 activation_client_->ActivateWindow(&app_state.window); |
| 552 EXPECT_EQ(ash::STATUS_ACTIVE, app_state.GetUpdaterItem().status); | 540 EXPECT_EQ(ash::STATUS_ACTIVE, app_state.GetUpdaterItem().status); |
| 553 } | 541 } |
| OLD | NEW |