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

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

Issue 10066015: ash: Replace launcher app type with Extension launch type. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/views/ash/launcher/launcher_updater.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 TestTabStripModelDelegate tab_strip_delegate; 236 TestTabStripModelDelegate tab_strip_delegate;
237 TabStripModel tab_strip(&tab_strip_delegate, profile()); 237 TabStripModel tab_strip(&tab_strip_delegate, profile());
238 TabContentsWrapper panel_tab(CreateTestWebContents()); 238 TabContentsWrapper panel_tab(CreateTestWebContents());
239 app_icon_loader_->SetAppID(&panel_tab, "1"); // Panels are apps. 239 app_icon_loader_->SetAppID(&panel_tab, "1"); // Panels are apps.
240 tab_strip.InsertTabContentsAt(0, &panel_tab, TabStripModel::ADD_ACTIVE); 240 tab_strip.InsertTabContentsAt(0, &panel_tab, TabStripModel::ADD_ACTIVE);
241 LauncherUpdater updater(&window, &tab_strip, launcher_delegate_.get(), 241 LauncherUpdater updater(&window, &tab_strip, launcher_delegate_.get(),
242 LauncherUpdater::TYPE_APP_PANEL, std::string()); 242 LauncherUpdater::TYPE_APP_PANEL, std::string());
243 updater.Init(); 243 updater.Init();
244 ASSERT_EQ(initial_size + 1, launcher_model_->items().size()); 244 ASSERT_EQ(initial_size + 1, launcher_model_->items().size());
245 EXPECT_EQ(ash::TYPE_APP_PANEL, GetItem(&updater).type); 245 EXPECT_EQ(ash::TYPE_APP_PANEL, GetItem(&updater).type);
246 ash::LauncherID id = GetItem(&updater).id;
247 EXPECT_EQ(ChromeLauncherDelegate::APP_TYPE_APP_PANEL,
248 launcher_delegate_->GetAppType(id));
249 EXPECT_EQ(static_cast<void*>(NULL), updater.favicon_loader_.get()); 246 EXPECT_EQ(static_cast<void*>(NULL), updater.favicon_loader_.get());
250 } 247 }
251 248
252 // Add an Extension panel. 249 // Add an Extension panel.
253 { 250 {
254 aura::Window window(NULL); 251 aura::Window window(NULL);
255 TestTabStripModelDelegate tab_strip_delegate; 252 TestTabStripModelDelegate tab_strip_delegate;
256 TabStripModel tab_strip(&tab_strip_delegate, profile()); 253 TabStripModel tab_strip(&tab_strip_delegate, profile());
257 TabContentsWrapper panel_tab(CreateTestWebContents()); 254 TabContentsWrapper panel_tab(CreateTestWebContents());
258 app_icon_loader_->SetAppID(&panel_tab, "1"); // Panels are apps. 255 app_icon_loader_->SetAppID(&panel_tab, "1"); // Panels are apps.
259 tab_strip.InsertTabContentsAt(0, &panel_tab, TabStripModel::ADD_ACTIVE); 256 tab_strip.InsertTabContentsAt(0, &panel_tab, TabStripModel::ADD_ACTIVE);
260 LauncherUpdater updater(&window, &tab_strip, launcher_delegate_.get(), 257 LauncherUpdater updater(&window, &tab_strip, launcher_delegate_.get(),
261 LauncherUpdater::TYPE_EXTENSION_PANEL, 258 LauncherUpdater::TYPE_EXTENSION_PANEL,
262 std::string()); 259 std::string());
263 updater.Init(); 260 updater.Init();
264 ASSERT_EQ(initial_size + 1, launcher_model_->items().size()); 261 ASSERT_EQ(initial_size + 1, launcher_model_->items().size());
265 EXPECT_EQ(ash::TYPE_APP_PANEL, GetItem(&updater).type); 262 EXPECT_EQ(ash::TYPE_APP_PANEL, GetItem(&updater).type);
266 ash::LauncherID id = GetItem(&updater).id;
267 EXPECT_EQ(ChromeLauncherDelegate::APP_TYPE_EXTENSION_PANEL,
268 launcher_delegate_->GetAppType(id));
269 EXPECT_NE(static_cast<void*>(NULL), updater.favicon_loader_.get()); 263 EXPECT_NE(static_cast<void*>(NULL), updater.favicon_loader_.get());
270 } 264 }
271 } 265 }
272 266
273 // Verifies pinned apps are persisted and restored. 267 // Verifies pinned apps are persisted and restored.
274 TEST_F(LauncherUpdaterTest, PersistPinned) { 268 TEST_F(LauncherUpdaterTest, PersistPinned) {
275 size_t initial_size = launcher_model_->items().size(); 269 size_t initial_size = launcher_model_->items().size();
276 TabContentsWrapper tab1(CreateTestWebContents()); 270 TabContentsWrapper tab1(CreateTestWebContents());
277 271
278 app_icon_loader_->SetAppID(&tab1, "1"); 272 app_icon_loader_->SetAppID(&tab1, "1");
279 273
280 app_icon_loader_->GetAndClearFetchCount(); 274 app_icon_loader_->GetAndClearFetchCount();
281 launcher_delegate_->PinAppWithID("1", 275 launcher_delegate_->PinAppWithID("1");
282 ChromeLauncherDelegate::APP_TYPE_WINDOW);
283 EXPECT_GT(app_icon_loader_->GetAndClearFetchCount(), 0); 276 EXPECT_GT(app_icon_loader_->GetAndClearFetchCount(), 0);
284 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, 277 EXPECT_EQ(ash::TYPE_APP_SHORTCUT,
285 launcher_model_->items()[1].type); 278 launcher_model_->items()[1].type);
286 EXPECT_TRUE(launcher_delegate_->IsAppPinned("1")); 279 EXPECT_TRUE(launcher_delegate_->IsAppPinned("1"));
287 EXPECT_FALSE(launcher_delegate_->IsAppPinned("0")); 280 EXPECT_FALSE(launcher_delegate_->IsAppPinned("0"));
288 EXPECT_EQ(initial_size + 1, launcher_model_->items().size()); 281 EXPECT_EQ(initial_size + 1, launcher_model_->items().size());
289 282
290 launcher_delegate_.reset( 283 launcher_delegate_.reset(
291 new ChromeLauncherDelegate(profile(), launcher_model_.get())); 284 new ChromeLauncherDelegate(profile(), launcher_model_.get()));
292 app_icon_loader_ = new AppIconLoaderImpl; 285 app_icon_loader_ = new AppIconLoaderImpl;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 EXPECT_EQ(&state1.window, activation_client_->GetActiveWindow()); 347 EXPECT_EQ(&state1.window, activation_client_->GetActiveWindow());
355 348
356 // And to the second item active. 349 // And to the second item active.
357 ash::LauncherItem new_item2(launcher_model_->items()[index2]); 350 ash::LauncherItem new_item2(launcher_model_->items()[index2]);
358 new_item2.status = ash::STATUS_ACTIVE; 351 new_item2.status = ash::STATUS_ACTIVE;
359 launcher_model_->Set(index2, new_item2); 352 launcher_model_->Set(index2, new_item2);
360 EXPECT_EQ(ash::STATUS_RUNNING, launcher_model_->items()[index1].status); 353 EXPECT_EQ(ash::STATUS_RUNNING, launcher_model_->items()[index1].status);
361 EXPECT_EQ(ash::STATUS_ACTIVE, launcher_model_->items()[index2].status); 354 EXPECT_EQ(ash::STATUS_ACTIVE, launcher_model_->items()[index2].status);
362 EXPECT_EQ(&state2.window, activation_client_->GetActiveWindow()); 355 EXPECT_EQ(&state2.window, activation_client_->GetActiveWindow());
363 } 356 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/ash/launcher/launcher_updater.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698