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

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

Issue 2702723002: Extract kArcEnabled preference from ArcSessionManager part 1. (Closed)
Patch Set: Address comments. 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>
(...skipping 23 matching lines...) Expand all
34 #include "base/json/json_string_value_serializer.h" 34 #include "base/json/json_string_value_serializer.h"
35 #include "base/location.h" 35 #include "base/location.h"
36 #include "base/macros.h" 36 #include "base/macros.h"
37 #include "base/memory/ptr_util.h" 37 #include "base/memory/ptr_util.h"
38 #include "base/run_loop.h" 38 #include "base/run_loop.h"
39 #include "base/single_thread_task_runner.h" 39 #include "base/single_thread_task_runner.h"
40 #include "base/strings/utf_string_conversions.h" 40 #include "base/strings/utf_string_conversions.h"
41 #include "base/values.h" 41 #include "base/values.h"
42 #include "build/build_config.h" 42 #include "build/build_config.h"
43 #include "chrome/browser/chromeos/arc/arc_support_host.h" 43 #include "chrome/browser/chromeos/arc/arc_support_host.h"
44 #include "chrome/browser/chromeos/arc/arc_util.h"
44 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" 45 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h"
45 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" 46 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
46 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" 47 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h"
47 #include "chrome/browser/extensions/extension_service.h" 48 #include "chrome/browser/extensions/extension_service.h"
48 #include "chrome/browser/extensions/test_extension_system.h" 49 #include "chrome/browser/extensions/test_extension_system.h"
49 #include "chrome/browser/lifetime/scoped_keep_alive.h" 50 #include "chrome/browser/lifetime/scoped_keep_alive.h"
50 #include "chrome/browser/prefs/browser_prefs.h" 51 #include "chrome/browser/prefs/browser_prefs.h"
51 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" 52 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h"
52 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" 53 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
53 #include "chrome/browser/ui/app_list/arc/arc_app_test.h" 54 #include "chrome/browser/ui/app_list/arc/arc_app_test.h"
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 arc_test_.app_instance()->SendRefreshAppList(arc_test_.fake_apps()); 818 arc_test_.app_instance()->SendRefreshAppList(arc_test_.fake_apps());
818 } 819 }
819 820
820 void UninstallArcApps() { 821 void UninstallArcApps() {
821 arc_test_.app_instance()->RefreshAppList(); 822 arc_test_.app_instance()->RefreshAppList();
822 arc_test_.app_instance()->SendRefreshAppList( 823 arc_test_.app_instance()->SendRefreshAppList(
823 std::vector<arc::mojom::AppInfo>()); 824 std::vector<arc::mojom::AppInfo>());
824 } 825 }
825 826
826 void EnableArc(bool enabled) { 827 void EnableArc(bool enabled) {
827 arc_test_.arc_session_manager()->SetArcPlayStoreEnabled(enabled); 828 arc::SetArcPlayStoreEnabledForProfile(profile(), enabled);
828 base::RunLoop().RunUntilIdle(); 829 base::RunLoop().RunUntilIdle();
829 } 830 }
830 831
831 void EnableTabletMode(bool enable) { 832 void EnableTabletMode(bool enable) {
832 ash::MaximizeModeController* controller = 833 ash::MaximizeModeController* controller =
833 ash::WmShell::Get()->maximize_mode_controller(); 834 ash::WmShell::Get()->maximize_mode_controller();
834 controller->EnableMaximizeModeWindowManager(enable); 835 controller->EnableMaximizeModeWindowManager(enable);
835 } 836 }
836 837
837 void ValidateArcState(bool arc_enabled, 838 void ValidateArcState(bool arc_enabled,
838 bool arc_managed, 839 bool arc_managed,
839 arc::ArcSessionManager::State state, 840 arc::ArcSessionManager::State state,
840 const std::string& pin_status) { 841 const std::string& pin_status) {
841 EXPECT_EQ(arc_enabled, 842 EXPECT_EQ(arc_enabled, arc::IsArcPlayStoreEnabledForProfile(profile()));
842 arc_test_.arc_session_manager()->IsArcPlayStoreEnabled()); 843 EXPECT_EQ(arc_managed,
843 EXPECT_EQ(arc_managed, arc_test_.arc_session_manager()->IsArcManaged()); 844 arc::IsArcPlayStoreEnabledPreferenceManagedForProfile(profile()));
844 EXPECT_EQ(state, arc_test_.arc_session_manager()->state()); 845 EXPECT_EQ(state, arc_test_.arc_session_manager()->state());
845 EXPECT_EQ(pin_status, GetPinnedAppStatus()); 846 EXPECT_EQ(pin_status, GetPinnedAppStatus());
846 } 847 }
847 848
848 // Creates app window and set optional ARC application id. 849 // Creates app window and set optional ARC application id.
849 views::Widget* CreateArcWindow(const std::string& window_app_id) { 850 views::Widget* CreateArcWindow(const std::string& window_app_id) {
850 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 851 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
851 params.bounds = gfx::Rect(5, 5, 20, 20); 852 params.bounds = gfx::Rect(5, 5, 20, 20);
852 params.context = GetContext(); 853 params.context = GetContext();
853 views::Widget* widget = new views::Widget(); 854 views::Widget* widget = new views::Widget();
(...skipping 3090 matching lines...) Expand 10 before | Expand all | Expand 10 after
3944 3945
3945 TEST_F(ChromeLauncherControllerArcDefaultAppsTest, DefaultApps) { 3946 TEST_F(ChromeLauncherControllerArcDefaultAppsTest, DefaultApps) {
3946 arc_test_.SetUp(profile()); 3947 arc_test_.SetUp(profile());
3947 InitLauncherController(); 3948 InitLauncherController();
3948 ChromeLauncherController::set_instance_for_test(launcher_controller_.get()); 3949 ChromeLauncherController::set_instance_for_test(launcher_controller_.get());
3949 arc::ArcSessionManager::SetShelfDelegateForTesting( 3950 arc::ArcSessionManager::SetShelfDelegateForTesting(
3950 launcher_controller_.get()); 3951 launcher_controller_.get());
3951 3952
3952 ArcAppListPrefs* const prefs = arc_test_.arc_app_list_prefs(); 3953 ArcAppListPrefs* const prefs = arc_test_.arc_app_list_prefs();
3953 EnableArc(false); 3954 EnableArc(false);
3954 EXPECT_FALSE(arc_test_.arc_session_manager()->IsArcPlayStoreEnabled()); 3955 EXPECT_FALSE(arc::IsArcPlayStoreEnabledForProfile(profile()));
3955 ASSERT_TRUE(prefs->GetAppIds().size()); 3956 ASSERT_TRUE(prefs->GetAppIds().size());
3956 3957
3957 const std::string app_id = 3958 const std::string app_id =
3958 ArcAppTest::GetAppId(arc_test_.fake_default_apps()[0]); 3959 ArcAppTest::GetAppId(arc_test_.fake_default_apps()[0]);
3959 EXPECT_EQ(ash::kInvalidShelfID, 3960 EXPECT_EQ(ash::kInvalidShelfID,
3960 launcher_controller_->GetShelfIDForAppID(app_id)); 3961 launcher_controller_->GetShelfIDForAppID(app_id));
3961 EXPECT_TRUE(arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON)); 3962 EXPECT_TRUE(arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON));
3962 EXPECT_TRUE(arc_test_.arc_session_manager()->IsArcPlayStoreEnabled()); 3963 EXPECT_TRUE(arc::IsArcPlayStoreEnabledForProfile(profile()));
3963 EXPECT_NE(ash::kInvalidShelfID, 3964 EXPECT_NE(ash::kInvalidShelfID,
3964 launcher_controller_->GetShelfIDForAppID(app_id)); 3965 launcher_controller_->GetShelfIDForAppID(app_id));
3965 3966
3966 // Stop ARC again. Shelf item should go away. 3967 // Stop ARC again. Shelf item should go away.
3967 EnableArc(false); 3968 EnableArc(false);
3968 EXPECT_EQ(ash::kInvalidShelfID, 3969 EXPECT_EQ(ash::kInvalidShelfID,
3969 launcher_controller_->GetShelfIDForAppID(app_id)); 3970 launcher_controller_->GetShelfIDForAppID(app_id));
3970 3971
3971 EXPECT_TRUE(arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON)); 3972 EXPECT_TRUE(arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON));
3972 EXPECT_TRUE(arc_test_.arc_session_manager()->IsArcPlayStoreEnabled()); 3973 EXPECT_TRUE(arc::IsArcPlayStoreEnabledForProfile(profile()));
3973 3974
3974 EXPECT_NE(ash::kInvalidShelfID, 3975 EXPECT_NE(ash::kInvalidShelfID,
3975 launcher_controller_->GetShelfIDForAppID(app_id)); 3976 launcher_controller_->GetShelfIDForAppID(app_id));
3976 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); 3977 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id));
3977 3978
3978 std::string window_app_id("org.chromium.arc.1"); 3979 std::string window_app_id("org.chromium.arc.1");
3979 CreateArcWindow(window_app_id); 3980 CreateArcWindow(window_app_id);
3980 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_default_apps()[0], 3981 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_default_apps()[0],
3981 std::string()); 3982 std::string());
3982 3983
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
4209 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, 4210 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
4210 shelf_controller->auto_hide()); 4211 shelf_controller->auto_hide());
4211 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count()); 4212 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count());
4212 4213
4213 PrefService* prefs = profile()->GetTestingPrefService(); 4214 PrefService* prefs = profile()->GetTestingPrefService();
4214 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal)); 4215 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal));
4215 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment)); 4216 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment));
4216 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal)); 4217 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal));
4217 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior)); 4218 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior));
4218 } 4219 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698