| 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/views/ash/launcher/launcher_updater.h" | 5 #include "chrome/browser/ui/views/ash/launcher/launcher_updater.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "ash/launcher/launcher_model.h" | 10 #include "ash/launcher/launcher_model.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 91 |
| 92 virtual void SetUp() OVERRIDE { | 92 virtual void SetUp() OVERRIDE { |
| 93 ChromeRenderViewHostTestHarness::SetUp(); | 93 ChromeRenderViewHostTestHarness::SetUp(); |
| 94 | 94 |
| 95 activation_client_.reset( | 95 activation_client_.reset( |
| 96 new aura::test::TestActivationClient(root_window())); | 96 new aura::test::TestActivationClient(root_window())); |
| 97 launcher_model_.reset(new ash::LauncherModel); | 97 launcher_model_.reset(new ash::LauncherModel); |
| 98 launcher_delegate_.reset( | 98 launcher_delegate_.reset( |
| 99 new ChromeLauncherDelegate(profile(), launcher_model_.get())); | 99 new ChromeLauncherDelegate(profile(), launcher_model_.get())); |
| 100 app_icon_loader_ = new AppIconLoaderImpl; | 100 app_icon_loader_ = new AppIconLoaderImpl; |
| 101 launcher_delegate_->SetAppIconLoaderForTest(app_icon_loader_); | 101 ResetAppIconLoader(); |
| 102 launcher_delegate_->Init(); | |
| 103 } | 102 } |
| 104 | 103 |
| 105 protected: | 104 protected: |
| 106 // Contains all the objects needed to create a LauncherUpdater. | 105 // Contains all the objects needed to create a LauncherUpdater. |
| 107 struct State : public aura::client::ActivationDelegate { | 106 struct State : public aura::client::ActivationDelegate { |
| 108 public: | 107 public: |
| 109 State(LauncherUpdaterTest* test, | 108 State(LauncherUpdaterTest* test, |
| 110 const std::string& app_id, | 109 const std::string& app_id, |
| 111 LauncherUpdater::Type launcher_type) | 110 LauncherUpdater::Type launcher_type) |
| 112 : launcher_test(test), | 111 : launcher_test(test), |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 153 |
| 155 LauncherUpdater* GetUpdaterByID(ash::LauncherID id) const { | 154 LauncherUpdater* GetUpdaterByID(ash::LauncherID id) const { |
| 156 return launcher_delegate_->id_to_item_map_[id].updater; | 155 return launcher_delegate_->id_to_item_map_[id].updater; |
| 157 } | 156 } |
| 158 | 157 |
| 159 const std::string& GetAppID(ash::LauncherID id) const { | 158 const std::string& GetAppID(ash::LauncherID id) const { |
| 160 return launcher_delegate_->id_to_item_map_[id].app_id; | 159 return launcher_delegate_->id_to_item_map_[id].app_id; |
| 161 } | 160 } |
| 162 | 161 |
| 163 void ResetAppIconLoader() { | 162 void ResetAppIconLoader() { |
| 164 launcher_delegate_->SetAppIconLoaderForTest(app_icon_loader_); | 163 launcher_delegate_->SetAppIconLoader(app_icon_loader_); |
| 165 } | 164 } |
| 166 | 165 |
| 167 void UnpinAppsWithID(const std::string& app_id) { | 166 void UnpinAppsWithID(const std::string& app_id) { |
| 168 launcher_delegate_->UnpinAppsWithID(app_id); | 167 launcher_delegate_->UnpinAppsWithID(app_id); |
| 169 } | 168 } |
| 170 | 169 |
| 171 ash::LauncherItem GetItem(LauncherUpdater& updater, | 170 ash::LauncherItem GetItem(LauncherUpdater& updater, |
| 172 TabContentsWrapper* tab) { | 171 TabContentsWrapper* tab) { |
| 173 LauncherUpdater::TestApi test_api(&updater); | 172 LauncherUpdater::TestApi test_api(&updater); |
| 174 ash::LauncherID launcher_id = test_api.GetLauncherID(tab); | 173 ash::LauncherID launcher_id = test_api.GetLauncherID(tab); |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 | 676 |
| 678 launcher_delegate_.reset(NULL); | 677 launcher_delegate_.reset(NULL); |
| 679 ASSERT_EQ(initial_size, launcher_model_->items().size()); | 678 ASSERT_EQ(initial_size, launcher_model_->items().size()); |
| 680 | 679 |
| 681 launcher_delegate_.reset( | 680 launcher_delegate_.reset( |
| 682 new ChromeLauncherDelegate(profile(), launcher_model_.get())); | 681 new ChromeLauncherDelegate(profile(), launcher_model_.get())); |
| 683 app_icon_loader_ = new AppIconLoaderImpl; | 682 app_icon_loader_ = new AppIconLoaderImpl; |
| 684 app_icon_loader_->SetAppID(&tab1, "1"); | 683 app_icon_loader_->SetAppID(&tab1, "1"); |
| 685 app_icon_loader_->SetAppID(NULL, "2"); | 684 app_icon_loader_->SetAppID(NULL, "2"); |
| 686 ResetAppIconLoader(); | 685 ResetAppIconLoader(); |
| 687 launcher_delegate_->Init(); | |
| 688 ASSERT_EQ(initial_size + 2, launcher_model_->items().size()); | 686 ASSERT_EQ(initial_size + 2, launcher_model_->items().size()); |
| 689 EXPECT_EQ(ash::TYPE_APP, launcher_model_->items()[initial_size].type); | 687 EXPECT_EQ(ash::TYPE_APP, launcher_model_->items()[initial_size].type); |
| 690 ash::LauncherID id = launcher_model_->items()[initial_size].id; | 688 ash::LauncherID id = launcher_model_->items()[initial_size].id; |
| 691 EXPECT_EQ("1", GetAppID(id)); | 689 EXPECT_EQ("1", GetAppID(id)); |
| 692 EXPECT_EQ(ChromeLauncherDelegate::APP_TYPE_TAB, | 690 EXPECT_EQ(ChromeLauncherDelegate::APP_TYPE_TAB, |
| 693 launcher_delegate_->GetAppType(id)); | 691 launcher_delegate_->GetAppType(id)); |
| 694 EXPECT_TRUE(launcher_delegate_->IsPinned(id)); | 692 EXPECT_TRUE(launcher_delegate_->IsPinned(id)); |
| 695 EXPECT_EQ(ash::TYPE_APP, launcher_model_->items()[initial_size + 1].type); | 693 EXPECT_EQ(ash::TYPE_APP, launcher_model_->items()[initial_size + 1].type); |
| 696 ash::LauncherID id2 = launcher_model_->items()[initial_size + 1].id; | 694 ash::LauncherID id2 = launcher_model_->items()[initial_size + 1].id; |
| 697 EXPECT_EQ("2", GetAppID(id2)); | 695 EXPECT_EQ("2", GetAppID(id2)); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 EXPECT_EQ(&state1.window, activation_client_->GetActiveWindow()); | 840 EXPECT_EQ(&state1.window, activation_client_->GetActiveWindow()); |
| 843 | 841 |
| 844 // And to the second item active. | 842 // And to the second item active. |
| 845 ash::LauncherItem new_item2(launcher_model_->items()[index2]); | 843 ash::LauncherItem new_item2(launcher_model_->items()[index2]); |
| 846 new_item2.status = ash::STATUS_ACTIVE; | 844 new_item2.status = ash::STATUS_ACTIVE; |
| 847 launcher_model_->Set(index2, new_item2); | 845 launcher_model_->Set(index2, new_item2); |
| 848 EXPECT_EQ(ash::STATUS_RUNNING, launcher_model_->items()[index1].status); | 846 EXPECT_EQ(ash::STATUS_RUNNING, launcher_model_->items()[index1].status); |
| 849 EXPECT_EQ(ash::STATUS_ACTIVE, launcher_model_->items()[index2].status); | 847 EXPECT_EQ(ash::STATUS_ACTIVE, launcher_model_->items()[index2].status); |
| 850 EXPECT_EQ(&state2.window, activation_client_->GetActiveWindow()); | 848 EXPECT_EQ(&state2.window, activation_client_->GetActiveWindow()); |
| 851 } | 849 } |
| OLD | NEW |