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

Unified Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_unittest.cc

Issue 2707133006: Start ARC and sign in after Chrome OS login (Closed)
Patch Set: test coverage in chrome_launcher_controller_impl_unittest.cc 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_unittest.cc
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_unittest.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_unittest.cc
index ac40fa9c3d67e2d73d8c1a1fe96f10174400d7c9..d496e9134f5053b3adc8decd68d0020ae1f9a828 100644
--- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_unittest.cc
+++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_unittest.cc
@@ -82,6 +82,7 @@
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/testing_profile_manager.h"
#include "chromeos/chromeos_switches.h"
+#include "components/arc/arc_util.h"
#include "components/arc/common/app.mojom.h"
#include "components/arc/test/fake_app_instance.h"
#include "components/exo/shell_surface.h"
@@ -823,7 +824,8 @@ class ChromeLauncherControllerImplTest : public BrowserWithTestWindowTest {
std::vector<arc::mojom::AppInfo>());
}
- void EnableArc(bool enabled) {
+ // TODO(victorhsieh): Add test coverage for Persistent ARC
+ void EnablePlay(bool enabled) {
arc_test_.arc_session_manager()->SetArcPlayStoreEnabled(enabled);
base::RunLoop().RunUntilIdle();
}
@@ -944,15 +946,26 @@ class ChromeLauncherControllerImplTest : public BrowserWithTestWindowTest {
};
class ChromeLauncherControllerImplWithArcTest
- : public ChromeLauncherControllerImplTest {
+ : public ChromeLauncherControllerImplTest,
+ public ::testing::WithParamInterface<bool> {
protected:
ChromeLauncherControllerImplWithArcTest() { auto_start_arc_test_ = true; }
~ChromeLauncherControllerImplWithArcTest() override {}
+ void SetUp() override {
+ if (GetParam())
+ arc::SetAlwaysStartArcForTesting();
+ ChromeLauncherControllerImplTest::SetUp();
+ }
+
private:
DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImplWithArcTest);
};
+INSTANTIATE_TEST_CASE_P(,
+ ChromeLauncherControllerImplWithArcTest,
+ ::testing::Bool());
+
// Watches WebContents and blocks until it is destroyed. This is needed for
// the destruction of a V2 application.
class WebContentsDestroyedWatcher : public content::WebContentsObserver {
@@ -1231,17 +1244,29 @@ class MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest
};
class ChromeLauncherControllerImplMultiProfileWithArcTest
- : public MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest { // NOLINT(whitespace/line_length)
+ : public MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, // NOLINT(whitespace/line_length)
+ public ::testing::WithParamInterface<bool> {
protected:
ChromeLauncherControllerImplMultiProfileWithArcTest() {
auto_start_arc_test_ = true;
}
~ChromeLauncherControllerImplMultiProfileWithArcTest() override {}
+ void SetUp() override {
+ if (GetParam())
+ arc::SetAlwaysStartArcForTesting();
+ MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest::
+ SetUp();
+ }
+
private:
DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImplMultiProfileWithArcTest);
};
+INSTANTIATE_TEST_CASE_P(,
+ ChromeLauncherControllerImplMultiProfileWithArcTest,
+ ::testing::Bool());
+
TEST_F(ChromeLauncherControllerImplTest, DefaultApps) {
InitLauncherController();
// Model should only contain the browser shortcut and app list items.
@@ -1258,7 +1283,7 @@ TEST_F(ChromeLauncherControllerImplTest, DefaultApps) {
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id()));
}
-TEST_F(ChromeLauncherControllerImplWithArcTest,
+TEST_P(ChromeLauncherControllerImplWithArcTest,
ArcAppPinCrossPlatformWorkflow) {
// Work on ARC disabled platform first.
const std::string arc_app_id1 =
@@ -1336,7 +1361,10 @@ TEST_F(ChromeLauncherControllerImplWithArcTest,
EXPECT_EQ(0U, app_service_->sync_items().size());
// Move back to ARC disabled platform.
- EnableArc(false);
+ // TODO(victorhsieh): Implement opt-out.
+ if (arc::ShouldAlwaysStartArc())
+ return;
+ EnablePlay(false);
StartAppSyncService(copy_sync_list);
RecreateChromeLauncher();
@@ -1352,7 +1380,7 @@ TEST_F(ChromeLauncherControllerImplWithArcTest,
model_->Move(4, 2);
launcher_controller_->UnpinAppWithID(extension2_->id());
EXPECT_EQ("AppList, App3, Chrome, App1", GetPinnedAppStatus());
- EnableArc(true);
+ EnablePlay(true);
SendListOfArcApps();
@@ -1789,7 +1817,7 @@ TEST_F(ChromeLauncherControllerImplTest, CheckRunningAppOrder) {
EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus());
}
-TEST_F(ChromeLauncherControllerImplWithArcTest, ArcDeferredLaunch) {
+TEST_P(ChromeLauncherControllerImplWithArcTest, ArcDeferredLaunch) {
RecreateChromeLauncher();
const arc::mojom::AppInfo& app1 = arc_test_.fake_apps()[0];
@@ -1864,7 +1892,7 @@ TEST_F(ChromeLauncherControllerImplWithArcTest, ArcDeferredLaunch) {
(request1->IsForApp(app3) && request2->IsForApp(app2)));
}
-TEST_F(ChromeLauncherControllerImplMultiProfileWithArcTest, ArcMultiUser) {
+TEST_P(ChromeLauncherControllerImplMultiProfileWithArcTest, ArcMultiUser) {
SendListOfArcApps();
InitLauncherController();
@@ -1936,7 +1964,7 @@ TEST_F(ChromeLauncherControllerImplMultiProfileWithArcTest, ArcMultiUser) {
arc_window3->CloseNow();
}
-TEST_F(ChromeLauncherControllerImplWithArcTest, ArcRunningApp) {
+TEST_P(ChromeLauncherControllerImplWithArcTest, ArcRunningApp) {
InitLauncherController();
const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
@@ -1979,7 +2007,7 @@ TEST_F(ChromeLauncherControllerImplWithArcTest, ArcRunningApp) {
// Test race creation/deletion of ARC app.
// TODO(khmel): Remove after moving everything to wayland protocol.
-TEST_F(ChromeLauncherControllerImplWithArcTest, ArcRaceCreateClose) {
+TEST_P(ChromeLauncherControllerImplWithArcTest, ArcRaceCreateClose) {
InitLauncherController();
const std::string arc_app_id1 =
@@ -2026,7 +2054,7 @@ TEST_F(ChromeLauncherControllerImplWithArcTest, ArcRaceCreateClose) {
launcher_controller_->GetShelfIDForAppID(arc_app_id2));
}
-TEST_F(ChromeLauncherControllerImplWithArcTest, ArcWindowRecreation) {
+TEST_P(ChromeLauncherControllerImplWithArcTest, ArcWindowRecreation) {
InitLauncherController();
const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
@@ -2055,7 +2083,7 @@ TEST_F(ChromeLauncherControllerImplWithArcTest, ArcWindowRecreation) {
// Validate that ARC app is pinned correctly and pin is removed automatically
// once app is uninstalled.
-TEST_F(ChromeLauncherControllerImplWithArcTest, ArcAppPin) {
+TEST_P(ChromeLauncherControllerImplWithArcTest, ArcAppPin) {
InitLauncherController();
const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
@@ -2077,9 +2105,15 @@ TEST_F(ChromeLauncherControllerImplWithArcTest, ArcAppPin) {
EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id()));
EXPECT_EQ("AppList, Chrome, App1, Fake App 0, App2", GetPinnedAppStatus());
+ // In opt-out mode, only system apps are available and can't be uninstalled.
+ // Skip the rest of the test.
+ if (arc::ShouldAlwaysStartArc())
+ return;
UninstallArcApps();
+ EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id));
EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus());
SendListOfArcApps();
+ EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id));
EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus());
// Disable/Enable ARC should persist pin state.
@@ -2091,16 +2125,16 @@ TEST_F(ChromeLauncherControllerImplWithArcTest, ArcAppPin) {
EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus());
// Opt-Out/Opt-In remove item from the shelf.
- EnableArc(false);
+ EnablePlay(false);
EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus());
- EnableArc(true);
+ EnablePlay(true);
EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus());
SendListOfArcApps();
EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus());
}
// Validates that ARC app pins persist across OptOut/OptIn.
-TEST_F(ChromeLauncherControllerImplWithArcTest, ArcAppPinOptOutOptIn) {
+TEST_P(ChromeLauncherControllerImplWithArcTest, ArcAppPinOptOutOptIn) {
InitLauncherController();
const std::string arc_app_id1 =
@@ -2124,7 +2158,10 @@ TEST_F(ChromeLauncherControllerImplWithArcTest, ArcAppPinOptOutOptIn) {
EXPECT_EQ("AppList, Chrome, App1, Fake App 1, App2, Fake App 0",
GetPinnedAppStatus());
- EnableArc(false);
+ // TODO(victorhsieh): Implement opt-out.
+ if (arc::ShouldAlwaysStartArc())
+ return;
+ EnablePlay(false);
EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus());
EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
@@ -2132,7 +2169,7 @@ TEST_F(ChromeLauncherControllerImplWithArcTest, ArcAppPinOptOutOptIn) {
EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id()));
EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id2));
- EnableArc(true);
+ EnablePlay(true);
SendListOfArcApps();
base::RunLoop().RunUntilIdle();
@@ -3555,7 +3592,7 @@ TEST_F(ChromeLauncherControllerImplTest, MultipleAppIconLoaders) {
EXPECT_EQ(1, app_icon_loader2->clear_count());
}
-TEST_F(ChromeLauncherControllerImplWithArcTest, ArcAppPinPolicy) {
+TEST_P(ChromeLauncherControllerImplWithArcTest, ArcAppPinPolicy) {
InitLauncherControllerWithBrowser();
arc::mojom::AppInfo appinfo = CreateAppInfo(
"Some App", "SomeActivity", "com.example.app", OrientationLock::NONE);
@@ -3574,10 +3611,14 @@ TEST_F(ChromeLauncherControllerImplWithArcTest, ArcAppPinPolicy) {
GetPinnableForAppID(app_id, profile()));
}
-TEST_F(ChromeLauncherControllerImplWithArcTest, ArcManaged) {
+TEST_P(ChromeLauncherControllerImplWithArcTest, ArcManaged) {
+ // TODO(victorhsieh): Implement opt-in and opt-out.
+ if (arc::ShouldAlwaysStartArc())
+ return;
+
extension_service_->AddExtension(arc_support_host_.get());
// Test enables ARC, so turn it off for initial values.
- EnableArc(false);
+ EnablePlay(false);
InitLauncherController();
@@ -3616,19 +3657,19 @@ TEST_F(ChromeLauncherControllerImplWithArcTest, ArcManaged) {
"AppList, Chrome, Play Store");
// ARC is not managed and enabled, Play Store pin should be available.
- EnableArc(true);
+ EnablePlay(true);
ValidateArcState(true, false,
arc::ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE,
"AppList, Chrome, Play Store");
// User disables ARC. ARC is not managed and disabled, Play Store pin should
// be automatically removed.
- EnableArc(false);
+ EnablePlay(false);
ValidateArcState(false, false, arc::ArcSessionManager::State::STOPPED,
"AppList, Chrome");
// Even if re-enable it again, Play Store pin does not appear automatically.
- EnableArc(true);
+ EnablePlay(true);
ValidateArcState(true, false,
arc::ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE,
"AppList, Chrome");
@@ -3710,14 +3751,21 @@ class ChromeLauncherControllerOrientationTest
DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerOrientationTest);
};
+INSTANTIATE_TEST_CASE_P(,
+ ChromeLauncherControllerOrientationTest,
+ ::testing::Bool());
+
class ChromeLauncherControllerArcDefaultAppsTest
- : public ChromeLauncherControllerImplTest {
+ : public ChromeLauncherControllerImplTest,
+ public ::testing::WithParamInterface<bool> {
public:
ChromeLauncherControllerArcDefaultAppsTest() {}
~ChromeLauncherControllerArcDefaultAppsTest() override {}
protected:
void SetUp() override {
+ if (GetParam())
+ arc::SetAlwaysStartArcForTesting();
ArcDefaultAppList::UseTestAppsDirectory();
ChromeLauncherControllerImplTest::SetUp();
}
@@ -3726,14 +3774,18 @@ class ChromeLauncherControllerArcDefaultAppsTest
DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerArcDefaultAppsTest);
};
+INSTANTIATE_TEST_CASE_P(,
+ ChromeLauncherControllerArcDefaultAppsTest,
+ ::testing::Bool());
+
} // namespace
-TEST_F(ChromeLauncherControllerOrientationTest,
+TEST_P(ChromeLauncherControllerOrientationTest,
ArcOrientationLockBeforeWindowReady) {
ASSERT_TRUE(display::Display::HasInternalDisplay());
extension_service_->AddExtension(arc_support_host_.get());
- EnableArc(true);
+ EnablePlay(true);
InitLauncherController();
arc::ArcSessionManager::SetShelfDelegateForTesting(
@@ -3780,11 +3832,11 @@ TEST_F(ChromeLauncherControllerOrientationTest,
display::Screen::GetScreen()->GetPrimaryDisplay().rotation());
}
-TEST_F(ChromeLauncherControllerOrientationTest, ArcOrientationLock) {
+TEST_P(ChromeLauncherControllerOrientationTest, ArcOrientationLock) {
ASSERT_TRUE(display::Display::HasInternalDisplay());
extension_service_->AddExtension(arc_support_host_.get());
- EnableArc(true);
+ EnablePlay(true);
EnableTabletMode(true);
InitLauncherController();
@@ -3879,11 +3931,11 @@ TEST_F(ChromeLauncherControllerOrientationTest, ArcOrientationLock) {
EXPECT_FALSE(controller->rotation_locked());
}
-TEST_F(ChromeLauncherControllerOrientationTest, CurrentWithLandscapeDisplay) {
+TEST_P(ChromeLauncherControllerOrientationTest, CurrentWithLandscapeDisplay) {
ASSERT_TRUE(display::Display::HasInternalDisplay());
extension_service_->AddExtension(arc_support_host_.get());
- EnableArc(true);
+ EnablePlay(true);
EnableTabletMode(true);
InitLauncherController();
@@ -3942,7 +3994,7 @@ TEST_F(ChromeLauncherControllerOrientationTest, CurrentWithLandscapeDisplay) {
display::Screen::GetScreen()->GetPrimaryDisplay().rotation());
}
-TEST_F(ChromeLauncherControllerArcDefaultAppsTest, DefaultApps) {
+TEST_P(ChromeLauncherControllerArcDefaultAppsTest, DefaultApps) {
arc_test_.SetUp(profile());
InitLauncherController();
ChromeLauncherController::set_instance_for_test(launcher_controller_.get());
@@ -3950,7 +4002,7 @@ TEST_F(ChromeLauncherControllerArcDefaultAppsTest, DefaultApps) {
launcher_controller_.get());
ArcAppListPrefs* const prefs = arc_test_.arc_app_list_prefs();
- EnableArc(false);
+ EnablePlay(false);
EXPECT_FALSE(arc_test_.arc_session_manager()->IsArcPlayStoreEnabled());
ASSERT_TRUE(prefs->GetAppIds().size());
@@ -3964,7 +4016,7 @@ TEST_F(ChromeLauncherControllerArcDefaultAppsTest, DefaultApps) {
launcher_controller_->GetShelfIDForAppID(app_id));
// Stop ARC again. Shelf item should go away.
- EnableArc(false);
+ EnablePlay(false);
EXPECT_EQ(ash::kInvalidShelfID,
launcher_controller_->GetShelfIDForAppID(app_id));

Powered by Google App Engine
This is Rietveld 408576698