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

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

Issue 12212120: Replace most BrowserList::empty() and BrowserList::size() calls by multi-desktop aware calls. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge up to r182110 Created 7 years, 10 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
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
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/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/file_path.h" 14 #include "base/file_path.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/message_loop.h" 16 #include "base/message_loop.h"
17 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
18 #include "base/values.h" 18 #include "base/values.h"
19 #include "chrome/browser/extensions/extension_service.h" 19 #include "chrome/browser/extensions/extension_service.h"
20 #include "chrome/browser/extensions/test_extension_system.h" 20 #include "chrome/browser/extensions/test_extension_system.h"
21 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" 21 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h"
22 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" 22 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h"
23 #include "chrome/browser/ui/browser_commands.h" 23 #include "chrome/browser/ui/browser_commands.h"
24 #include "chrome/browser/ui/browser_finder.h"
24 #include "chrome/browser/ui/browser_list.h" 25 #include "chrome/browser/ui/browser_list.h"
25 #include "chrome/browser/ui/tabs/tab_strip_model.h" 26 #include "chrome/browser/ui/tabs/tab_strip_model.h"
26 #include "chrome/common/extensions/extension.h" 27 #include "chrome/common/extensions/extension.h"
27 #include "chrome/common/pref_names.h" 28 #include "chrome/common/pref_names.h"
28 #include "chrome/test/base/browser_with_test_window_test.h" 29 #include "chrome/test/base/browser_with_test_window_test.h"
29 #include "chrome/test/base/testing_pref_service_syncable.h" 30 #include "chrome/test/base/testing_pref_service_syncable.h"
30 #include "chrome/test/base/testing_profile.h" 31 #include "chrome/test/base/testing_profile.h"
31 #include "content/public/test/test_browser_thread.h" 32 #include "content/public/test/test_browser_thread.h"
32 #include "testing/gtest/include/gtest/gtest.h" 33 #include "testing/gtest/include/gtest/gtest.h"
33 #include "ui/base/models/menu_model.h" 34 #include "ui/base/models/menu_model.h"
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 EXPECT_EQ(expected_menu_items, menu->GetItemCount()); 311 EXPECT_EQ(expected_menu_items, menu->GetItemCount());
311 EXPECT_FALSE(menu->IsEnabledAt(first_item)); 312 EXPECT_FALSE(menu->IsEnabledAt(first_item));
312 if (expected_items) { 313 if (expected_items) {
313 EXPECT_EQ(ui::MenuModel::TYPE_SEPARATOR, 314 EXPECT_EQ(ui::MenuModel::TYPE_SEPARATOR,
314 menu->GetTypeAt(first_item + 1)); 315 menu->GetTypeAt(first_item + 1));
315 } 316 }
316 } 317 }
317 318
318 // Check that browsers get reflected correctly in the launcher menu. 319 // Check that browsers get reflected correctly in the launcher menu.
319 TEST_F(ChromeLauncherControllerPerAppTest, BrowserMenuGeneration) { 320 TEST_F(ChromeLauncherControllerPerAppTest, BrowserMenuGeneration) {
320 EXPECT_EQ(1U, BrowserList::size()); 321 EXPECT_EQ(1U, chrome::GetTotalBrowserCount());
321 chrome::NewTab(browser()); 322 chrome::NewTab(browser());
322 323
323 ChromeLauncherControllerPerApp launcher_controller(profile(), &model_); 324 ChromeLauncherControllerPerApp launcher_controller(profile(), &model_);
324 launcher_controller.Init(); 325 launcher_controller.Init();
325 326
326 // Check that the browser list is empty at this time. 327 // Check that the browser list is empty at this time.
327 ash::LauncherItem item_browser; 328 ash::LauncherItem item_browser;
328 item_browser.type = ash::TYPE_BROWSER_SHORTCUT; 329 item_browser.type = ash::TYPE_BROWSER_SHORTCUT;
329 CheckMenuCreation(&launcher_controller, item_browser, 0, NULL, true); 330 CheckMenuCreation(&launcher_controller, item_browser, 0, NULL, true);
330 331
(...skipping 25 matching lines...) Expand all
356 357
357 // Apparently we have to close all tabs we have. 358 // Apparently we have to close all tabs we have.
358 chrome::CloseTab(browser2.get()); 359 chrome::CloseTab(browser2.get());
359 } 360 }
360 361
361 // Check that V1 apps are correctly reflected in the launcher menu using the 362 // Check that V1 apps are correctly reflected in the launcher menu using the
362 // refocus logic. 363 // refocus logic.
363 // Note that the extension matching logic is tested by the extension system 364 // Note that the extension matching logic is tested by the extension system
364 // and does not need a separate test here. 365 // and does not need a separate test here.
365 TEST_F(ChromeLauncherControllerPerAppTest, V1AppMenuGeneration) { 366 TEST_F(ChromeLauncherControllerPerAppTest, V1AppMenuGeneration) {
366 EXPECT_EQ(1U, BrowserList::size()); 367 EXPECT_EQ(1U, chrome::GetTotalBrowserCount());
367 EXPECT_EQ(0, browser()->tab_strip_model()->count()); 368 EXPECT_EQ(0, browser()->tab_strip_model()->count());
368 chrome::NewTab(browser()); 369 chrome::NewTab(browser());
369 BrowserList::SetLastActive(browser()); 370 BrowserList::SetLastActive(browser());
370 371
371 ChromeLauncherControllerPerApp launcher_controller(profile(), &model_); 372 ChromeLauncherControllerPerApp launcher_controller(profile(), &model_);
372 launcher_controller.Init(); 373 launcher_controller.Init();
373 374
374 // Model should only contain the browser shortcut and app list items. 375 // Model should only contain the browser shortcut and app list items.
375 EXPECT_EQ(2, model_.item_count()); 376 EXPECT_EQ(2, model_.item_count());
376 EXPECT_FALSE(launcher_controller.IsAppPinned(extension3_->id())); 377 EXPECT_FALSE(launcher_controller.IsAppPinned(extension3_->id()));
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 { 482 {
482 scoped_ptr<ui::MenuModel> menu( 483 scoped_ptr<ui::MenuModel> menu(
483 launcher_controller.CreateApplicationMenu(item_gmail)); 484 launcher_controller.CreateApplicationMenu(item_gmail));
484 int first_item = 485 int first_item =
485 (menu->GetTypeAt(0) == ui::MenuModel::TYPE_SEPARATOR) ? 1 : 0; 486 (menu->GetTypeAt(0) == ui::MenuModel::TYPE_SEPARATOR) ? 1 : 0;
486 menu->ActivatedAt(first_item + 3); 487 menu->ActivatedAt(first_item + 3);
487 } 488 }
488 // Now the active tab should be the second item. 489 // Now the active tab should be the second item.
489 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); 490 EXPECT_EQ(0, browser()->tab_strip_model()->active_index());
490 } 491 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.cc ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698