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

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

Issue 2700783002: s/\bArc\b/ARC/g for ARC related code. (Closed)
Patch Set: Address ARC++ Created 3 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
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 827 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 bool arc_managed, 838 bool arc_managed,
839 arc::ArcSessionManager::State state, 839 arc::ArcSessionManager::State state,
840 const std::string& pin_status) { 840 const std::string& pin_status) {
841 EXPECT_EQ(arc_enabled, 841 EXPECT_EQ(arc_enabled,
842 arc_test_.arc_session_manager()->IsArcPlayStoreEnabled()); 842 arc_test_.arc_session_manager()->IsArcPlayStoreEnabled());
843 EXPECT_EQ(arc_managed, arc_test_.arc_session_manager()->IsArcManaged()); 843 EXPECT_EQ(arc_managed, arc_test_.arc_session_manager()->IsArcManaged());
844 EXPECT_EQ(state, arc_test_.arc_session_manager()->state()); 844 EXPECT_EQ(state, arc_test_.arc_session_manager()->state());
845 EXPECT_EQ(pin_status, GetPinnedAppStatus()); 845 EXPECT_EQ(pin_status, GetPinnedAppStatus());
846 } 846 }
847 847
848 // Creates app window and set optional Arc application id. 848 // Creates app window and set optional ARC application id.
849 views::Widget* CreateArcWindow(const std::string& window_app_id) { 849 views::Widget* CreateArcWindow(const std::string& window_app_id) {
850 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 850 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
851 params.bounds = gfx::Rect(5, 5, 20, 20); 851 params.bounds = gfx::Rect(5, 5, 20, 20);
852 params.context = GetContext(); 852 params.context = GetContext();
853 views::Widget* widget = new views::Widget(); 853 views::Widget* widget = new views::Widget();
854 widget->Init(params); 854 widget->Init(params);
855 // Set Arc id before showing the window to be recognized in 855 // Set ARC id before showing the window to be recognized in
856 // ArcAppWindowLauncherController. 856 // ArcAppWindowLauncherController.
857 exo::ShellSurface::SetApplicationId(widget->GetNativeWindow(), 857 exo::ShellSurface::SetApplicationId(widget->GetNativeWindow(),
858 window_app_id); 858 window_app_id);
859 widget->Show(); 859 widget->Show();
860 widget->Activate(); 860 widget->Activate();
861 return widget; 861 return widget;
862 } 862 }
863 863
864 arc::mojom::AppInfo CreateAppInfo(const std::string& name, 864 arc::mojom::AppInfo CreateAppInfo(const std::string& name,
865 const std::string& activity, 865 const std::string& activity,
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
1253 // Installing |extension3_| should add it to the launcher - behind the 1253 // Installing |extension3_| should add it to the launcher - behind the
1254 // chrome icon. 1254 // chrome icon.
1255 extension_service_->AddExtension(extension3_.get()); 1255 extension_service_->AddExtension(extension3_.get());
1256 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus()); 1256 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus());
1257 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1257 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1258 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); 1258 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id()));
1259 } 1259 }
1260 1260
1261 TEST_F(ChromeLauncherControllerImplWithArcTest, 1261 TEST_F(ChromeLauncherControllerImplWithArcTest,
1262 ArcAppPinCrossPlatformWorkflow) { 1262 ArcAppPinCrossPlatformWorkflow) {
1263 // Work on Arc-disabled platform first. 1263 // Work on ARC disabled platform first.
1264 const std::string arc_app_id1 = 1264 const std::string arc_app_id1 =
1265 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); 1265 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
1266 const std::string arc_app_id2 = 1266 const std::string arc_app_id2 =
1267 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); 1267 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]);
1268 const std::string arc_app_id3 = 1268 const std::string arc_app_id3 =
1269 ArcAppTest::GetAppId(arc_test_.fake_apps()[2]); 1269 ArcAppTest::GetAppId(arc_test_.fake_apps()[2]);
1270 1270
1271 InitLauncherController(); 1271 InitLauncherController();
1272 1272
1273 extension_service_->AddExtension(extension1_.get()); 1273 extension_service_->AddExtension(extension1_.get());
(...skipping 11 matching lines...) Expand all
1285 SetShelfChromeIconIndex(1); 1285 SetShelfChromeIconIndex(1);
1286 1286
1287 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); 1287 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
1288 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id1)); 1288 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id1));
1289 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); 1289 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id()));
1290 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id2)); 1290 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id2));
1291 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); 1291 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id()));
1292 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id3)); 1292 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id3));
1293 EXPECT_EQ("AppList, App1, Chrome, App2, App3", GetPinnedAppStatus()); 1293 EXPECT_EQ("AppList, App1, Chrome, App2, App3", GetPinnedAppStatus());
1294 1294
1295 // Persist pin state, we don't have active pin for Arc apps yet, but pin 1295 // Persist pin state, we don't have active pin for ARC apps yet, but pin
1296 // model should have it. 1296 // model should have it.
1297 syncer::SyncDataList copy_sync_list = 1297 syncer::SyncDataList copy_sync_list =
1298 app_service_->GetAllSyncData(syncer::APP_LIST); 1298 app_service_->GetAllSyncData(syncer::APP_LIST);
1299 1299
1300 launcher_controller_.reset(); 1300 launcher_controller_.reset();
1301 SendPinChanges(syncer::SyncChangeList(), true); 1301 SendPinChanges(syncer::SyncChangeList(), true);
1302 StopAppSyncService(); 1302 StopAppSyncService();
1303 EXPECT_EQ(0U, app_service_->sync_items().size()); 1303 EXPECT_EQ(0U, app_service_->sync_items().size());
1304 1304
1305 // Move to Arc-enabled platform, restart syncing with stored data. 1305 // Move to ARC enabled platform, restart syncing with stored data.
1306 StartAppSyncService(copy_sync_list); 1306 StartAppSyncService(copy_sync_list);
1307 RecreateChromeLauncher(); 1307 RecreateChromeLauncher();
1308 1308
1309 // Pins must be automatically updated. 1309 // Pins must be automatically updated.
1310 SendListOfArcApps(); 1310 SendListOfArcApps();
1311 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); 1311 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
1312 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id1)); 1312 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id1));
1313 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); 1313 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id()));
1314 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id2)); 1314 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id2));
1315 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); 1315 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id()));
1316 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id3)); 1316 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id3));
1317 1317
1318 EXPECT_EQ("AppList, App1, Chrome, Fake App 0, App2, Fake App 1, App3", 1318 EXPECT_EQ("AppList, App1, Chrome, Fake App 0, App2, Fake App 1, App3",
1319 GetPinnedAppStatus()); 1319 GetPinnedAppStatus());
1320 1320
1321 // Now move pins on Arc-enabled platform. 1321 // Now move pins on ARC enabled platform.
1322 model_->Move(1, 4); 1322 model_->Move(1, 4);
1323 model_->Move(3, 1); 1323 model_->Move(3, 1);
1324 model_->Move(3, 5); 1324 model_->Move(3, 5);
1325 model_->Move(4, 2); 1325 model_->Move(4, 2);
1326 EXPECT_EQ("AppList, App2, Fake App 1, Chrome, App1, Fake App 0, App3", 1326 EXPECT_EQ("AppList, App2, Fake App 1, Chrome, App1, Fake App 0, App3",
1327 GetPinnedAppStatus()); 1327 GetPinnedAppStatus());
1328 1328
1329 copy_sync_list = app_service_->GetAllSyncData(syncer::APP_LIST); 1329 copy_sync_list = app_service_->GetAllSyncData(syncer::APP_LIST);
1330 1330
1331 launcher_controller_.reset(); 1331 launcher_controller_.reset();
1332 ResetPinModel(); 1332 ResetPinModel();
1333 1333
1334 SendPinChanges(syncer::SyncChangeList(), true); 1334 SendPinChanges(syncer::SyncChangeList(), true);
1335 StopAppSyncService(); 1335 StopAppSyncService();
1336 EXPECT_EQ(0U, app_service_->sync_items().size()); 1336 EXPECT_EQ(0U, app_service_->sync_items().size());
1337 1337
1338 // Move back to Arc-disabled platform. 1338 // Move back to ARC disabled platform.
1339 EnableArc(false); 1339 EnableArc(false);
1340 StartAppSyncService(copy_sync_list); 1340 StartAppSyncService(copy_sync_list);
1341 RecreateChromeLauncher(); 1341 RecreateChromeLauncher();
1342 1342
1343 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); 1343 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
1344 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id1)); 1344 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id1));
1345 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); 1345 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id()));
1346 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id2)); 1346 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id2));
1347 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); 1347 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id()));
1348 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id3)); 1348 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id3));
1349 EXPECT_EQ("AppList, App2, Chrome, App1, App3", GetPinnedAppStatus()); 1349 EXPECT_EQ("AppList, App2, Chrome, App1, App3", GetPinnedAppStatus());
1350 1350
1351 // Now move/remove pins on Arc-disabled platform. 1351 // Now move/remove pins on ARC disabled platform.
1352 model_->Move(4, 2); 1352 model_->Move(4, 2);
1353 launcher_controller_->UnpinAppWithID(extension2_->id()); 1353 launcher_controller_->UnpinAppWithID(extension2_->id());
1354 EXPECT_EQ("AppList, App3, Chrome, App1", GetPinnedAppStatus()); 1354 EXPECT_EQ("AppList, App3, Chrome, App1", GetPinnedAppStatus());
1355 EnableArc(true); 1355 EnableArc(true);
1356 1356
1357 SendListOfArcApps(); 1357 SendListOfArcApps();
1358 1358
1359 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); 1359 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
1360 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id1)); 1360 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id1));
1361 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); 1361 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id()));
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
1970 arc_test_.app_instance()->SendTaskCreated(3, arc_test_.fake_apps()[0], 1970 arc_test_.app_instance()->SendTaskCreated(3, arc_test_.fake_apps()[0],
1971 std::string()); 1971 std::string());
1972 EXPECT_NE(ash::kInvalidShelfID, 1972 EXPECT_NE(ash::kInvalidShelfID,
1973 launcher_controller_->GetShelfIDForAppID(arc_app_id)); 1973 launcher_controller_->GetShelfIDForAppID(arc_app_id));
1974 arc_test_.StopArcInstance(); 1974 arc_test_.StopArcInstance();
1975 base::RunLoop().RunUntilIdle(); 1975 base::RunLoop().RunUntilIdle();
1976 EXPECT_EQ(ash::kInvalidShelfID, 1976 EXPECT_EQ(ash::kInvalidShelfID,
1977 launcher_controller_->GetShelfIDForAppID(arc_app_id)); 1977 launcher_controller_->GetShelfIDForAppID(arc_app_id));
1978 } 1978 }
1979 1979
1980 // Test race creation/deletion of Arc app. 1980 // Test race creation/deletion of ARC app.
1981 // TODO(khmel): Remove after moving everything to wayland protocol. 1981 // TODO(khmel): Remove after moving everything to wayland protocol.
1982 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcRaceCreateClose) { 1982 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcRaceCreateClose) {
1983 InitLauncherController(); 1983 InitLauncherController();
1984 1984
1985 const std::string arc_app_id1 = 1985 const std::string arc_app_id1 =
1986 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); 1986 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
1987 const std::string arc_app_id2 = 1987 const std::string arc_app_id2 =
1988 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); 1988 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]);
1989 SendListOfArcApps(); 1989 SendListOfArcApps();
1990 1990
1991 // Arc window created before and closed after mojom notification. 1991 // ARC window created before and closed after mojom notification.
1992 std::string window_app_id1("org.chromium.arc.1"); 1992 std::string window_app_id1("org.chromium.arc.1");
1993 views::Widget* arc_window = CreateArcWindow(window_app_id1); 1993 views::Widget* arc_window = CreateArcWindow(window_app_id1);
1994 EXPECT_EQ(ash::kInvalidShelfID, 1994 EXPECT_EQ(ash::kInvalidShelfID,
1995 launcher_controller_->GetShelfIDForAppID(arc_app_id1)); 1995 launcher_controller_->GetShelfIDForAppID(arc_app_id1));
1996 ASSERT_TRUE(arc_window); 1996 ASSERT_TRUE(arc_window);
1997 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0], 1997 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0],
1998 std::string()); 1998 std::string());
1999 EXPECT_NE(ash::kInvalidShelfID, 1999 EXPECT_NE(ash::kInvalidShelfID,
2000 launcher_controller_->GetShelfIDForAppID(arc_app_id1)); 2000 launcher_controller_->GetShelfIDForAppID(arc_app_id1));
2001 arc_test_.app_instance()->SendTaskDestroyed(1); 2001 arc_test_.app_instance()->SendTaskDestroyed(1);
2002 EXPECT_EQ(ash::kInvalidShelfID, 2002 EXPECT_EQ(ash::kInvalidShelfID,
2003 launcher_controller_->GetShelfIDForAppID(arc_app_id1)); 2003 launcher_controller_->GetShelfIDForAppID(arc_app_id1));
2004 arc_window->Close(); 2004 arc_window->Close();
2005 base::RunLoop().RunUntilIdle(); 2005 base::RunLoop().RunUntilIdle();
2006 EXPECT_EQ(ash::kInvalidShelfID, 2006 EXPECT_EQ(ash::kInvalidShelfID,
2007 launcher_controller_->GetShelfIDForAppID(arc_app_id1)); 2007 launcher_controller_->GetShelfIDForAppID(arc_app_id1));
2008 2008
2009 // Arc window created after and closed before mojom notification. 2009 // ARC window created after and closed before mojom notification.
2010 std::string window_app_id2("org.chromium.arc.2"); 2010 std::string window_app_id2("org.chromium.arc.2");
2011 arc_test_.app_instance()->SendTaskCreated(2, arc_test_.fake_apps()[1], 2011 arc_test_.app_instance()->SendTaskCreated(2, arc_test_.fake_apps()[1],
2012 std::string()); 2012 std::string());
2013 EXPECT_NE(ash::kInvalidShelfID, 2013 EXPECT_NE(ash::kInvalidShelfID,
2014 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); 2014 launcher_controller_->GetShelfIDForAppID(arc_app_id2));
2015 arc_window = CreateArcWindow(window_app_id2); 2015 arc_window = CreateArcWindow(window_app_id2);
2016 ASSERT_TRUE(arc_window); 2016 ASSERT_TRUE(arc_window);
2017 EXPECT_NE(ash::kInvalidShelfID, 2017 EXPECT_NE(ash::kInvalidShelfID,
2018 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); 2018 launcher_controller_->GetShelfIDForAppID(arc_app_id2));
2019 arc_window->Close(); 2019 arc_window->Close();
(...skipping 26 matching lines...) Expand all
2046 base::RunLoop().RunUntilIdle(); 2046 base::RunLoop().RunUntilIdle();
2047 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id)); 2047 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id));
2048 2048
2049 arc_window = CreateArcWindow(window_app_id); 2049 arc_window = CreateArcWindow(window_app_id);
2050 ASSERT_TRUE(arc_window); 2050 ASSERT_TRUE(arc_window);
2051 base::RunLoop().RunUntilIdle(); 2051 base::RunLoop().RunUntilIdle();
2052 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id)); 2052 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id));
2053 } 2053 }
2054 } 2054 }
2055 2055
2056 // Validate that Arc app is pinned correctly and pin is removed automatically 2056 // Validate that ARC app is pinned correctly and pin is removed automatically
2057 // once app is uninstalled. 2057 // once app is uninstalled.
2058 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcAppPin) { 2058 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcAppPin) {
2059 InitLauncherController(); 2059 InitLauncherController();
2060 2060
2061 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); 2061 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
2062 2062
2063 SendListOfArcApps(); 2063 SendListOfArcApps();
2064 extension_service_->AddExtension(extension1_.get()); 2064 extension_service_->AddExtension(extension1_.get());
2065 extension_service_->AddExtension(extension2_.get()); 2065 extension_service_->AddExtension(extension2_.get());
2066 2066
2067 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 2067 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
2068 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id)); 2068 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id));
2069 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); 2069 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id()));
2070 2070
2071 launcher_controller_->PinAppWithID(extension1_->id()); 2071 launcher_controller_->PinAppWithID(extension1_->id());
2072 launcher_controller_->PinAppWithID(arc_app_id); 2072 launcher_controller_->PinAppWithID(arc_app_id);
2073 launcher_controller_->PinAppWithID(extension2_->id()); 2073 launcher_controller_->PinAppWithID(extension2_->id());
2074 2074
2075 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); 2075 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
2076 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id)); 2076 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id));
2077 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); 2077 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id()));
2078 2078
2079 EXPECT_EQ("AppList, Chrome, App1, Fake App 0, App2", GetPinnedAppStatus()); 2079 EXPECT_EQ("AppList, Chrome, App1, Fake App 0, App2", GetPinnedAppStatus());
2080 UninstallArcApps(); 2080 UninstallArcApps();
2081 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); 2081 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus());
2082 SendListOfArcApps(); 2082 SendListOfArcApps();
2083 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); 2083 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus());
2084 2084
2085 // Disable/Enable Arc should persist pin state. 2085 // Disable/Enable ARC should persist pin state.
2086 launcher_controller_->PinAppWithID(arc_app_id); 2086 launcher_controller_->PinAppWithID(arc_app_id);
2087 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus()); 2087 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus());
2088 arc::ArcSessionManager::Get()->Shutdown(); 2088 arc::ArcSessionManager::Get()->Shutdown();
2089 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus()); 2089 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus());
2090 arc::ArcSessionManager::Get()->OnPrimaryUserProfilePrepared(profile()); 2090 arc::ArcSessionManager::Get()->OnPrimaryUserProfilePrepared(profile());
2091 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus()); 2091 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus());
2092 2092
2093 // Opt-Out/Opt-In remove item from the shelf. 2093 // Opt-Out/Opt-In remove item from the shelf.
2094 EnableArc(false); 2094 EnableArc(false);
2095 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); 2095 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus());
2096 EnableArc(true); 2096 EnableArc(true);
2097 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); 2097 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus());
2098 SendListOfArcApps(); 2098 SendListOfArcApps();
2099 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus()); 2099 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus());
2100 } 2100 }
2101 2101
2102 // Validates that Arc app pins persist across OptOut/OptIn. 2102 // Validates that ARC app pins persist across OptOut/OptIn.
2103 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcAppPinOptOutOptIn) { 2103 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcAppPinOptOutOptIn) {
2104 InitLauncherController(); 2104 InitLauncherController();
2105 2105
2106 const std::string arc_app_id1 = 2106 const std::string arc_app_id1 =
2107 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); 2107 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
2108 const std::string arc_app_id2 = 2108 const std::string arc_app_id2 =
2109 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); 2109 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]);
2110 2110
2111 SendListOfArcApps(); 2111 SendListOfArcApps();
2112 extension_service_->AddExtension(extension1_.get()); 2112 extension_service_->AddExtension(extension1_.get());
(...skipping 1456 matching lines...) Expand 10 before | Expand all | Expand 10 after
3569 profile()->GetTestingPrefService()->SetManagedPref( 3569 profile()->GetTestingPrefService()->SetManagedPref(
3570 prefs::kPolicyPinnedLauncherApps, policy_value.DeepCopy()); 3570 prefs::kPolicyPinnedLauncherApps, policy_value.DeepCopy());
3571 3571
3572 EXPECT_TRUE(launcher_controller_->IsAppPinned(app_id)); 3572 EXPECT_TRUE(launcher_controller_->IsAppPinned(app_id));
3573 EXPECT_EQ(AppListControllerDelegate::PIN_FIXED, 3573 EXPECT_EQ(AppListControllerDelegate::PIN_FIXED,
3574 GetPinnableForAppID(app_id, profile())); 3574 GetPinnableForAppID(app_id, profile()));
3575 } 3575 }
3576 3576
3577 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcManaged) { 3577 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcManaged) {
3578 extension_service_->AddExtension(arc_support_host_.get()); 3578 extension_service_->AddExtension(arc_support_host_.get());
3579 // Test enables Arc, so turn it off for initial values. 3579 // Test enables ARC, so turn it off for initial values.
3580 EnableArc(false); 3580 EnableArc(false);
3581 3581
3582 InitLauncherController(); 3582 InitLauncherController();
3583 3583
3584 // To prevent import legacy pins each time. 3584 // To prevent import legacy pins each time.
3585 // Initially pins are imported from legacy pref based model. 3585 // Initially pins are imported from legacy pref based model.
3586 StartPrefSyncService(syncer::SyncDataList()); 3586 StartPrefSyncService(syncer::SyncDataList());
3587 3587
3588 arc::ArcSessionManager::SetShelfDelegateForTesting( 3588 arc::ArcSessionManager::SetShelfDelegateForTesting(
3589 launcher_controller_.get()); 3589 launcher_controller_.get());
3590 3590
3591 // Initial run, Arc is not managed and disabled, Play Store pin should be 3591 // Initial run, ARC is not managed and disabled, Play Store pin should be
3592 // available. 3592 // available.
3593 ValidateArcState(false, false, arc::ArcSessionManager::State::STOPPED, 3593 ValidateArcState(false, false, arc::ArcSessionManager::State::STOPPED,
3594 "AppList, Chrome, Play Store"); 3594 "AppList, Chrome, Play Store");
3595 3595
3596 // Arc is managed and enabled, Play Store pin should be available. 3596 // ARC is managed and enabled, Play Store pin should be available.
3597 // Note: SHOWING_TERMS_OF_SERVICE here means that opt-in flow starts. 3597 // Note: SHOWING_TERMS_OF_SERVICE here means that opt-in flow starts.
3598 profile()->GetTestingPrefService()->SetManagedPref( 3598 profile()->GetTestingPrefService()->SetManagedPref(
3599 prefs::kArcEnabled, new base::FundamentalValue(true)); 3599 prefs::kArcEnabled, new base::FundamentalValue(true));
3600 base::RunLoop().RunUntilIdle(); 3600 base::RunLoop().RunUntilIdle();
3601 ValidateArcState(true, true, 3601 ValidateArcState(true, true,
3602 arc::ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, 3602 arc::ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE,
3603 "AppList, Chrome, Play Store"); 3603 "AppList, Chrome, Play Store");
3604 3604
3605 // Arc is managed and disabled, Play Store pin should not be available. 3605 // ARC is managed and disabled, Play Store pin should not be available.
3606 profile()->GetTestingPrefService()->SetManagedPref( 3606 profile()->GetTestingPrefService()->SetManagedPref(
3607 prefs::kArcEnabled, new base::FundamentalValue(false)); 3607 prefs::kArcEnabled, new base::FundamentalValue(false));
3608 base::RunLoop().RunUntilIdle(); 3608 base::RunLoop().RunUntilIdle();
3609 ValidateArcState(false, true, arc::ArcSessionManager::State::STOPPED, 3609 ValidateArcState(false, true, arc::ArcSessionManager::State::STOPPED,
3610 "AppList, Chrome"); 3610 "AppList, Chrome");
3611 3611
3612 // Arc is not managed and disabled, Play Store pin should be available. 3612 // ARC is not managed and disabled, Play Store pin should be available.
3613 profile()->GetTestingPrefService()->RemoveManagedPref(prefs::kArcEnabled); 3613 profile()->GetTestingPrefService()->RemoveManagedPref(prefs::kArcEnabled);
3614 base::RunLoop().RunUntilIdle(); 3614 base::RunLoop().RunUntilIdle();
3615 ValidateArcState(false, false, arc::ArcSessionManager::State::STOPPED, 3615 ValidateArcState(false, false, arc::ArcSessionManager::State::STOPPED,
3616 "AppList, Chrome, Play Store"); 3616 "AppList, Chrome, Play Store");
3617 3617
3618 // Arc is not managed and enabled, Play Store pin should be available. 3618 // ARC is not managed and enabled, Play Store pin should be available.
3619 EnableArc(true); 3619 EnableArc(true);
3620 ValidateArcState(true, false, 3620 ValidateArcState(true, false,
3621 arc::ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, 3621 arc::ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE,
3622 "AppList, Chrome, Play Store"); 3622 "AppList, Chrome, Play Store");
3623 3623
3624 // User disables Arc. Arc is not managed and disabled, Play Store pin should 3624 // User disables ARC. ARC is not managed and disabled, Play Store pin should
3625 // be automatically removed. 3625 // be automatically removed.
3626 EnableArc(false); 3626 EnableArc(false);
3627 ValidateArcState(false, false, arc::ArcSessionManager::State::STOPPED, 3627 ValidateArcState(false, false, arc::ArcSessionManager::State::STOPPED,
3628 "AppList, Chrome"); 3628 "AppList, Chrome");
3629 3629
3630 // Even if re-enable it again, Play Store pin does not appear automatically. 3630 // Even if re-enable it again, Play Store pin does not appear automatically.
3631 EnableArc(true); 3631 EnableArc(true);
3632 ValidateArcState(true, false, 3632 ValidateArcState(true, false,
3633 arc::ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, 3633 arc::ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE,
3634 "AppList, Chrome"); 3634 "AppList, Chrome");
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
3956 3956
3957 const std::string app_id = 3957 const std::string app_id =
3958 ArcAppTest::GetAppId(arc_test_.fake_default_apps()[0]); 3958 ArcAppTest::GetAppId(arc_test_.fake_default_apps()[0]);
3959 EXPECT_EQ(ash::kInvalidShelfID, 3959 EXPECT_EQ(ash::kInvalidShelfID,
3960 launcher_controller_->GetShelfIDForAppID(app_id)); 3960 launcher_controller_->GetShelfIDForAppID(app_id));
3961 EXPECT_TRUE(arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON)); 3961 EXPECT_TRUE(arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON));
3962 EXPECT_TRUE(arc_test_.arc_session_manager()->IsArcPlayStoreEnabled()); 3962 EXPECT_TRUE(arc_test_.arc_session_manager()->IsArcPlayStoreEnabled());
3963 EXPECT_NE(ash::kInvalidShelfID, 3963 EXPECT_NE(ash::kInvalidShelfID,
3964 launcher_controller_->GetShelfIDForAppID(app_id)); 3964 launcher_controller_->GetShelfIDForAppID(app_id));
3965 3965
3966 // Stop Arc again. Shelf item should go away. 3966 // Stop ARC again. Shelf item should go away.
3967 EnableArc(false); 3967 EnableArc(false);
3968 EXPECT_EQ(ash::kInvalidShelfID, 3968 EXPECT_EQ(ash::kInvalidShelfID,
3969 launcher_controller_->GetShelfIDForAppID(app_id)); 3969 launcher_controller_->GetShelfIDForAppID(app_id));
3970 3970
3971 EXPECT_TRUE(arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON)); 3971 EXPECT_TRUE(arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON));
3972 EXPECT_TRUE(arc_test_.arc_session_manager()->IsArcPlayStoreEnabled()); 3972 EXPECT_TRUE(arc_test_.arc_session_manager()->IsArcPlayStoreEnabled());
3973 3973
3974 EXPECT_NE(ash::kInvalidShelfID, 3974 EXPECT_NE(ash::kInvalidShelfID,
3975 launcher_controller_->GetShelfIDForAppID(app_id)); 3975 launcher_controller_->GetShelfIDForAppID(app_id));
3976 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); 3976 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id));
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
4209 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, 4209 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
4210 shelf_controller->auto_hide()); 4210 shelf_controller->auto_hide());
4211 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count()); 4211 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count());
4212 4212
4213 PrefService* prefs = profile()->GetTestingPrefService(); 4213 PrefService* prefs = profile()->GetTestingPrefService();
4214 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal)); 4214 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal));
4215 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment)); 4215 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment));
4216 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal)); 4216 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal));
4217 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior)); 4217 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior));
4218 } 4218 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698