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

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

Issue 2761373002: Move yet more from WmShell to Shell (Closed)
Patch Set: merge Created 3 years, 9 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_impl.h" 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
11 #include <memory> 11 #include <memory>
12 #include <set> 12 #include <set>
13 #include <string> 13 #include <string>
14 #include <utility> 14 #include <utility>
15 #include <vector> 15 #include <vector>
16 16
17 #include "ash/common/shelf/shelf_application_menu_model.h" 17 #include "ash/common/shelf/shelf_application_menu_model.h"
18 #include "ash/common/shelf/shelf_constants.h" 18 #include "ash/common/shelf/shelf_constants.h"
19 #include "ash/common/shelf/shelf_controller.h" 19 #include "ash/common/shelf/shelf_controller.h"
20 #include "ash/common/shelf/shelf_model.h" 20 #include "ash/common/shelf/shelf_model.h"
21 #include "ash/common/shelf/shelf_model_observer.h" 21 #include "ash/common/shelf/shelf_model_observer.h"
22 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" 22 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
23 #include "ash/common/wm_shell.h" 23 #include "ash/common/wm_shell.h"
24 #include "ash/display/screen_orientation_controller_chromeos.h" 24 #include "ash/display/screen_orientation_controller_chromeos.h"
25 #include "ash/public/cpp/app_launch_id.h" 25 #include "ash/public/cpp/app_launch_id.h"
26 #include "ash/public/cpp/shelf_item.h" 26 #include "ash/public/cpp/shelf_item.h"
27 #include "ash/shell.h" 27 #include "ash/shell.h"
28 #include "ash/test/ash_test_helper.h" 28 #include "ash/test/ash_test_helper.h"
29 #include "ash/test/shell_test_api.h"
29 #include "ash/test/test_shell_delegate.h" 30 #include "ash/test/test_shell_delegate.h"
30 #include "ash/wm/window_util.h" 31 #include "ash/wm/window_util.h"
31 #include "base/command_line.h" 32 #include "base/command_line.h"
32 #include "base/compiler_specific.h" 33 #include "base/compiler_specific.h"
33 #include "base/files/file_path.h" 34 #include "base/files/file_path.h"
34 #include "base/json/json_string_value_serializer.h" 35 #include "base/json/json_string_value_serializer.h"
35 #include "base/location.h" 36 #include "base/location.h"
36 #include "base/macros.h" 37 #include "base/macros.h"
37 #include "base/memory/ptr_util.h" 38 #include "base/memory/ptr_util.h"
38 #include "base/run_loop.h" 39 #include "base/run_loop.h"
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 app_list::AppListSyncableServiceFactory::SetUseInTesting(); 339 app_list::AppListSyncableServiceFactory::SetUseInTesting();
339 340
340 BrowserWithTestWindowTest::SetUp(); 341 BrowserWithTestWindowTest::SetUp();
341 342
342 if (!profile_manager_) { 343 if (!profile_manager_) {
343 profile_manager_.reset( 344 profile_manager_.reset(
344 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); 345 new TestingProfileManager(TestingBrowserProcess::GetGlobal()));
345 ASSERT_TRUE(profile_manager_->SetUp()); 346 ASSERT_TRUE(profile_manager_->SetUp());
346 } 347 }
347 348
348 model_ = ash::WmShell::Get()->shelf_controller()->model(); 349 model_ = ash::Shell::Get()->shelf_controller()->model();
349 model_observer_.reset(new TestShelfModelObserver); 350 model_observer_.reset(new TestShelfModelObserver);
350 model_->AddObserver(model_observer_.get()); 351 model_->AddObserver(model_observer_.get());
351 352
352 base::DictionaryValue manifest; 353 base::DictionaryValue manifest;
353 manifest.SetString(extensions::manifest_keys::kName, 354 manifest.SetString(extensions::manifest_keys::kName,
354 "launcher controller test extension"); 355 "launcher controller test extension");
355 manifest.SetString(extensions::manifest_keys::kVersion, "1"); 356 manifest.SetString(extensions::manifest_keys::kVersion, "1");
356 manifest.SetString(extensions::manifest_keys::kDescription, 357 manifest.SetString(extensions::manifest_keys::kDescription,
357 "for testing pinned apps"); 358 "for testing pinned apps");
358 359
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 model_->RemoveItemAt(0); 545 model_->RemoveItemAt(0);
545 AddAppListLauncherItem(); 546 AddAppListLauncherItem();
546 launcher_controller_ = 547 launcher_controller_ =
547 base::MakeUnique<ChromeLauncherControllerImpl>(profile(), model_); 548 base::MakeUnique<ChromeLauncherControllerImpl>(profile(), model_);
548 launcher_controller_->Init(); 549 launcher_controller_->Init();
549 } 550 }
550 551
551 // This needs to be called after InitLaunchController(), or its family. 552 // This needs to be called after InitLaunchController(), or its family.
552 // It is not supported to recreate the instance. 553 // It is not supported to recreate the instance.
553 void SetShelfDelegate() { 554 void SetShelfDelegate() {
554 ash::WmShell::Get()->SetShelfDelegateForTesting( 555 ash::test::ShellTestApi().SetShelfDelegate(
555 base::MakeUnique<ProxyShelfDelegate>(launcher_controller_.get())); 556 base::MakeUnique<ProxyShelfDelegate>(launcher_controller_.get()));
556 } 557 }
557 558
558 void StartAppSyncService(const syncer::SyncDataList& init_sync_list) { 559 void StartAppSyncService(const syncer::SyncDataList& init_sync_list) {
559 app_service_->MergeDataAndStartSyncing( 560 app_service_->MergeDataAndStartSyncing(
560 syncer::APP_LIST, init_sync_list, 561 syncer::APP_LIST, init_sync_list,
561 base::MakeUnique<syncer::FakeSyncChangeProcessor>(), 562 base::MakeUnique<syncer::FakeSyncChangeProcessor>(),
562 base::MakeUnique<syncer::SyncErrorFactoryMock>()); 563 base::MakeUnique<syncer::SyncErrorFactoryMock>());
563 EXPECT_EQ(init_sync_list.size(), app_service_->sync_items().size()); 564 EXPECT_EQ(init_sync_list.size(), app_service_->sync_items().size());
564 } 565 }
(...skipping 3725 matching lines...) Expand 10 before | Expand all | Expand 10 after
4290 using ChromeLauncherControllerImplPrefTest = BrowserWithTestWindowTest; 4291 using ChromeLauncherControllerImplPrefTest = BrowserWithTestWindowTest;
4291 4292
4292 // Tests that shelf profile preferences are loaded on login. 4293 // Tests that shelf profile preferences are loaded on login.
4293 TEST_F(ChromeLauncherControllerImplPrefTest, PrefsLoadedOnLogin) { 4294 TEST_F(ChromeLauncherControllerImplPrefTest, PrefsLoadedOnLogin) {
4294 PrefService* prefs = profile()->GetTestingPrefService(); 4295 PrefService* prefs = profile()->GetTestingPrefService();
4295 prefs->SetString(prefs::kShelfAlignmentLocal, "Left"); 4296 prefs->SetString(prefs::kShelfAlignmentLocal, "Left");
4296 prefs->SetString(prefs::kShelfAlignment, "Left"); 4297 prefs->SetString(prefs::kShelfAlignment, "Left");
4297 prefs->SetString(prefs::kShelfAutoHideBehaviorLocal, "Always"); 4298 prefs->SetString(prefs::kShelfAutoHideBehaviorLocal, "Always");
4298 prefs->SetString(prefs::kShelfAutoHideBehavior, "Always"); 4299 prefs->SetString(prefs::kShelfAutoHideBehavior, "Always");
4299 4300
4300 ash::ShelfModel* model = ash::WmShell::Get()->shelf_controller()->model(); 4301 ash::ShelfModel* model = ash::Shell::Get()->shelf_controller()->model();
4301 TestChromeLauncherControllerImpl test_launcher_controller(profile(), model); 4302 TestChromeLauncherControllerImpl test_launcher_controller(profile(), model);
4302 test_launcher_controller.Init(); 4303 test_launcher_controller.Init();
4303 4304
4304 // Simulate login for the test controller. 4305 // Simulate login for the test controller.
4305 test_launcher_controller.ReleaseProfile(); 4306 test_launcher_controller.ReleaseProfile();
4306 test_launcher_controller.AttachProfile(profile()); 4307 test_launcher_controller.AttachProfile(profile());
4307 base::RunLoop().RunUntilIdle(); 4308 base::RunLoop().RunUntilIdle();
4308 4309
4309 TestShelfController* shelf_controller = 4310 TestShelfController* shelf_controller =
4310 test_launcher_controller.test_shelf_controller(); 4311 test_launcher_controller.test_shelf_controller();
4311 ASSERT_TRUE(shelf_controller); 4312 ASSERT_TRUE(shelf_controller);
4312 EXPECT_EQ(ash::SHELF_ALIGNMENT_LEFT, shelf_controller->alignment()); 4313 EXPECT_EQ(ash::SHELF_ALIGNMENT_LEFT, shelf_controller->alignment());
4313 EXPECT_EQ(1u, shelf_controller->alignment_change_count()); 4314 EXPECT_EQ(1u, shelf_controller->alignment_change_count());
4314 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, 4315 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
4315 shelf_controller->auto_hide()); 4316 shelf_controller->auto_hide());
4316 EXPECT_EQ(1u, shelf_controller->auto_hide_change_count()); 4317 EXPECT_EQ(1u, shelf_controller->auto_hide_change_count());
4317 } 4318 }
4318 4319
4319 // Tests that the shelf controller's changes are not wastefully echoed back. 4320 // Tests that the shelf controller's changes are not wastefully echoed back.
4320 TEST_F(ChromeLauncherControllerImplPrefTest, DoNotEchoShelfControllerChanges) { 4321 TEST_F(ChromeLauncherControllerImplPrefTest, DoNotEchoShelfControllerChanges) {
4321 ash::ShelfModel* model = ash::WmShell::Get()->shelf_controller()->model(); 4322 ash::ShelfModel* model = ash::Shell::Get()->shelf_controller()->model();
4322 TestChromeLauncherControllerImpl test_launcher_controller(profile(), model); 4323 TestChromeLauncherControllerImpl test_launcher_controller(profile(), model);
4323 test_launcher_controller.Init(); 4324 test_launcher_controller.Init();
4324 4325
4325 // Simulate login for the test controller. 4326 // Simulate login for the test controller.
4326 test_launcher_controller.ReleaseProfile(); 4327 test_launcher_controller.ReleaseProfile();
4327 test_launcher_controller.AttachProfile(profile()); 4328 test_launcher_controller.AttachProfile(profile());
4328 base::RunLoop().RunUntilIdle(); 4329 base::RunLoop().RunUntilIdle();
4329 4330
4330 TestShelfController* shelf_controller = 4331 TestShelfController* shelf_controller =
4331 test_launcher_controller.test_shelf_controller(); 4332 test_launcher_controller.test_shelf_controller();
(...skipping 19 matching lines...) Expand all
4351 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, 4352 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
4352 shelf_controller->auto_hide()); 4353 shelf_controller->auto_hide());
4353 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count()); 4354 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count());
4354 4355
4355 PrefService* prefs = profile()->GetTestingPrefService(); 4356 PrefService* prefs = profile()->GetTestingPrefService();
4356 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal)); 4357 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal));
4357 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment)); 4358 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment));
4358 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal)); 4359 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal));
4359 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior)); 4360 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior));
4360 } 4361 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698