Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Side by Side Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app_unittest.cc

Issue 17673004: Insert panel icons on the left of other panel icons. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Add condition to per browser launcher controller as well. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/chrome_launcher_controller_per_app.h" 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 removed_(0), 57 removed_(0),
58 changed_(0) { 58 changed_(0) {
59 } 59 }
60 60
61 virtual ~TestLauncherModelObserver() { 61 virtual ~TestLauncherModelObserver() {
62 } 62 }
63 63
64 // LauncherModelObserver 64 // LauncherModelObserver
65 virtual void LauncherItemAdded(int index) OVERRIDE { 65 virtual void LauncherItemAdded(int index) OVERRIDE {
66 ++added_; 66 ++added_;
67 last_index_ = index;
67 } 68 }
68 69
69 virtual void LauncherItemRemoved(int index, ash::LauncherID id) OVERRIDE { 70 virtual void LauncherItemRemoved(int index, ash::LauncherID id) OVERRIDE {
70 ++removed_; 71 ++removed_;
72 last_index_ = index;
71 } 73 }
72 74
73 virtual void LauncherItemChanged(int index, 75 virtual void LauncherItemChanged(int index,
74 const ash::LauncherItem& old_item) OVERRIDE { 76 const ash::LauncherItem& old_item) OVERRIDE {
75 ++changed_; 77 ++changed_;
78 last_index_ = index;
76 } 79 }
77 80
78 virtual void LauncherItemMoved(int start_index, int target_index) OVERRIDE { 81 virtual void LauncherItemMoved(int start_index, int target_index) OVERRIDE {
82 last_index_ = target_index;
79 } 83 }
80 84
81 virtual void LauncherStatusChanged() OVERRIDE { 85 virtual void LauncherStatusChanged() OVERRIDE {
82 } 86 }
83 87
84 void clear_counts() { 88 void clear_counts() {
85 added_ = 0; 89 added_ = 0;
86 removed_ = 0; 90 removed_ = 0;
87 changed_ = 0; 91 changed_ = 0;
92 last_index_ = 0;
88 } 93 }
89 94
90 int added() const { return added_; } 95 int added() const { return added_; }
91 int removed() const { return removed_; } 96 int removed() const { return removed_; }
92 int changed() const { return changed_; } 97 int changed() const { return changed_; }
98 int last_index() const { return last_index_; }
93 99
94 private: 100 private:
95 int added_; 101 int added_;
96 int removed_; 102 int removed_;
97 int changed_; 103 int changed_;
104 int last_index_;
98 105
99 DISALLOW_COPY_AND_ASSIGN(TestLauncherModelObserver); 106 DISALLOW_COPY_AND_ASSIGN(TestLauncherModelObserver);
100 }; 107 };
101 108
102 // Test implementation of AppIconLoader. 109 // Test implementation of AppIconLoader.
103 class TestAppIconLoaderImpl : public extensions::AppIconLoader { 110 class TestAppIconLoaderImpl : public extensions::AppIconLoader {
104 public: 111 public:
105 TestAppIconLoaderImpl() : fetch_count_(0) { 112 TestAppIconLoaderImpl() : fetch_count_(0) {
106 } 113 }
107 114
(...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 TestAppIconLoaderImpl* app_icon_loader = new TestAppIconLoaderImpl(); 1061 TestAppIconLoaderImpl* app_icon_loader = new TestAppIconLoaderImpl();
1055 SetAppIconLoader(app_icon_loader); 1062 SetAppIconLoader(app_icon_loader);
1056 1063
1057 // Test adding an app panel 1064 // Test adding an app panel
1058 std::string app_id = extension1_->id(); 1065 std::string app_id = extension1_->id();
1059 ShellWindowLauncherItemController app_panel_controller( 1066 ShellWindowLauncherItemController app_panel_controller(
1060 LauncherItemController::TYPE_APP_PANEL, "id", app_id, 1067 LauncherItemController::TYPE_APP_PANEL, "id", app_id,
1061 launcher_controller_.get()); 1068 launcher_controller_.get());
1062 ash::LauncherID launcher_id1 = launcher_controller_->CreateAppLauncherItem( 1069 ash::LauncherID launcher_id1 = launcher_controller_->CreateAppLauncherItem(
1063 &app_panel_controller, app_id, ash::STATUS_RUNNING); 1070 &app_panel_controller, app_id, ash::STATUS_RUNNING);
1071 int panel_index = model_observer_->last_index();
1064 EXPECT_EQ(2, model_observer_->added()); 1072 EXPECT_EQ(2, model_observer_->added());
1065 EXPECT_EQ(0, model_observer_->changed()); 1073 EXPECT_EQ(0, model_observer_->changed());
1066 EXPECT_EQ(1, app_icon_loader->fetch_count()); 1074 EXPECT_EQ(1, app_icon_loader->fetch_count());
1067 model_observer_->clear_counts(); 1075 model_observer_->clear_counts();
1068 1076
1069 // App panels should have a separate identifier than the app id 1077 // App panels should have a separate identifier than the app id
1070 EXPECT_EQ(0, launcher_controller_->GetLauncherIDForAppID(app_id)); 1078 EXPECT_EQ(0, launcher_controller_->GetLauncherIDForAppID(app_id));
1071 1079
1072 // Setting the app image image should not change the panel if it set its icon 1080 // Setting the app image image should not change the panel if it set its icon
1073 app_panel_controller.set_image_set_by_controller(true); 1081 app_panel_controller.set_image_set_by_controller(true);
1074 gfx::ImageSkia image; 1082 gfx::ImageSkia image;
1075 launcher_controller_->SetAppImage(app_id, image); 1083 launcher_controller_->SetAppImage(app_id, image);
1076 EXPECT_EQ(0, model_observer_->changed()); 1084 EXPECT_EQ(0, model_observer_->changed());
1085 model_observer_->clear_counts();
1077 1086
1087 // Add a second app panel and verify that it get the same index as the first
1088 // one had, being added to the left of the existing panel.
1089 ash::LauncherID launcher_id2 = launcher_controller_->CreateAppLauncherItem(
1090 &app_panel_controller, app_id, ash::STATUS_RUNNING);
1091 EXPECT_EQ(panel_index, model_observer_->last_index());
1092 EXPECT_EQ(1, model_observer_->added());
1093 model_observer_->clear_counts();
1094
1095 launcher_controller_->CloseLauncherItem(launcher_id2);
1078 launcher_controller_->CloseLauncherItem(launcher_id1); 1096 launcher_controller_->CloseLauncherItem(launcher_id1);
1079 EXPECT_EQ(1, model_observer_->removed()); 1097 EXPECT_EQ(2, model_observer_->removed());
1080 } 1098 }
1081 1099
1082 // Tests that the Gmail extension matches more then the app itself claims with 1100 // Tests that the Gmail extension matches more then the app itself claims with
1083 // the manifest file. 1101 // the manifest file.
1084 TEST_F(ChromeLauncherControllerPerAppTest, GmailMatching) { 1102 TEST_F(ChromeLauncherControllerPerAppTest, GmailMatching) {
1085 InitLauncherControllerWithBrowser(); 1103 InitLauncherControllerWithBrowser();
1086 1104
1087 // Create a Gmail browser tab. 1105 // Create a Gmail browser tab.
1088 chrome::NewTab(browser()); 1106 chrome::NewTab(browser());
1089 string16 title = ASCIIToUTF16("Test"); 1107 string16 title = ASCIIToUTF16("Test");
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1129 ash::LauncherID gmail_id = model_->next_id(); 1147 ash::LauncherID gmail_id = model_->next_id();
1130 extension_service_->AddExtension(extension3_.get()); 1148 extension_service_->AddExtension(extension3_.get());
1131 EXPECT_EQ(3, model_->item_count()); 1149 EXPECT_EQ(3, model_->item_count());
1132 int gmail_index = model_->ItemIndexByID(gmail_id); 1150 int gmail_index = model_->ItemIndexByID(gmail_id);
1133 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[gmail_index].type); 1151 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[gmail_index].type);
1134 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); 1152 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id()));
1135 1153
1136 // The content should not be able to be handled by the app. 1154 // The content should not be able to be handled by the app.
1137 EXPECT_FALSE(launcher_controller_->ContentCanBeHandledByGmailApp(content)); 1155 EXPECT_FALSE(launcher_controller_->ContentCanBeHandledByGmailApp(content));
1138 } 1156 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698