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

Unified Diff: chrome/browser/chromeos/note_taking_helper_unittest.cc

Issue 2707133006: Start ARC and sign in after Chrome OS login (Closed)
Patch Set: 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/chromeos/note_taking_helper_unittest.cc
diff --git a/chrome/browser/chromeos/note_taking_helper_unittest.cc b/chrome/browser/chromeos/note_taking_helper_unittest.cc
index 86480d71ab6d4e1fae98277b9253af8c5e01146a..2cec015e899e6d1d1b24820d64f26a9e80c2f034 100644
--- a/chrome/browser/chromeos/note_taking_helper_unittest.cc
+++ b/chrome/browser/chromeos/note_taking_helper_unittest.cc
@@ -117,12 +117,15 @@ class TestObserver : public NoteTakingHelper::Observer {
} // namespace
-class NoteTakingHelperTest : public BrowserWithTestWindowTest {
+class NoteTakingHelperTest : public BrowserWithTestWindowTest,
+ public ::testing::WithParamInterface<bool> {
public:
NoteTakingHelperTest() = default;
~NoteTakingHelperTest() override = default;
void SetUp() override {
+ ArcAppTest::Init(GetParam());
+
// This is needed to avoid log spam due to ArcSessionManager's
// RemoveArcData() calls failing.
if (DBusThreadManager::IsInitialized())
@@ -149,6 +152,10 @@ class NoteTakingHelperTest : public BrowserWithTestWindowTest {
DBusThreadManager::Shutdown();
}
+ bool IsPersistentArc() {
+ return arc_test_.arc_session_manager()->IsPersistentArc();
+ }
+
protected:
// Information about a Chrome app passed to LaunchChromeApp().
struct ChromeAppLaunchInfo {
@@ -158,7 +165,7 @@ class NoteTakingHelperTest : public BrowserWithTestWindowTest {
// Options that can be passed to Init().
enum InitFlags {
- ENABLE_ARC = 1 << 0,
+ ENABLE_PLAY = 1 << 0,
ENABLE_PALETTE = 1 << 1,
};
@@ -170,7 +177,7 @@ class NoteTakingHelperTest : public BrowserWithTestWindowTest {
ASSERT_FALSE(initialized_);
initialized_ = true;
- profile()->GetPrefs()->SetBoolean(prefs::kArcEnabled, flags & ENABLE_ARC);
+ profile()->GetPrefs()->SetBoolean(prefs::kArcEnabled, flags & ENABLE_PLAY);
arc_test_.SetUp(profile());
arc::ArcServiceManager::Get()
->arc_bridge_service()
@@ -183,7 +190,7 @@ class NoteTakingHelperTest : public BrowserWithTestWindowTest {
}
// TODO(derat): Sigh, something in ArcAppTest appears to be re-enabling ARC.
- profile()->GetPrefs()->SetBoolean(prefs::kArcEnabled, flags & ENABLE_ARC);
+ profile()->GetPrefs()->SetBoolean(prefs::kArcEnabled, flags & ENABLE_PLAY);
NoteTakingHelper::Initialize();
NoteTakingHelper::Get()->set_launch_chrome_app_callback_for_test(base::Bind(
&NoteTakingHelperTest::LaunchChromeApp, base::Unretained(this)));
@@ -288,7 +295,9 @@ class NoteTakingHelperTest : public BrowserWithTestWindowTest {
DISALLOW_COPY_AND_ASSIGN(NoteTakingHelperTest);
};
-TEST_F(NoteTakingHelperTest, PaletteNotEnabled) {
+INSTANTIATE_TEST_CASE_P(, NoteTakingHelperTest, ::testing::Values(false, true));
+
+TEST_P(NoteTakingHelperTest, PaletteNotEnabled) {
// Without the palette enabled, IsAppAvailable() should return false.
Init(0);
auto extension =
@@ -297,7 +306,7 @@ TEST_F(NoteTakingHelperTest, PaletteNotEnabled) {
EXPECT_FALSE(helper()->IsAppAvailable(profile()));
}
-TEST_F(NoteTakingHelperTest, ListChromeApps) {
+TEST_P(NoteTakingHelperTest, ListChromeApps) {
Init(ENABLE_PALETTE);
// Start out without any note-taking apps installed.
@@ -359,7 +368,7 @@ TEST_F(NoteTakingHelperTest, ListChromeApps) {
// Verify the note helper detects apps with "new_note" "action_handler" manifest
// entries.
-TEST_F(NoteTakingHelperTest, CustomChromeApps) {
+TEST_P(NoteTakingHelperTest, CustomChromeApps) {
Init(ENABLE_PALETTE);
const extensions::ExtensionId kNewNoteId = crx_file::id_util::GenerateId("a");
@@ -389,7 +398,7 @@ TEST_F(NoteTakingHelperTest, CustomChromeApps) {
EXPECT_EQ(GetAppString(kNewNoteId, kName, false), GetAppString(apps[0]));
}
-TEST_F(NoteTakingHelperTest, WhitelistedAndCustomAppsShowOnlyOnce) {
+TEST_P(NoteTakingHelperTest, WhitelistedAndCustomAppsShowOnlyOnce) {
Init(ENABLE_PALETTE);
auto extension = CreateExtension(
@@ -405,7 +414,7 @@ TEST_F(NoteTakingHelperTest, WhitelistedAndCustomAppsShowOnlyOnce) {
GetAppString(apps[0]));
}
-TEST_F(NoteTakingHelperTest, LaunchChromeApp) {
+TEST_P(NoteTakingHelperTest, LaunchChromeApp) {
Init(ENABLE_PALETTE);
auto extension =
CreateExtension(NoteTakingHelper::kProdKeepExtensionId, "Keep");
@@ -428,7 +437,7 @@ TEST_F(NoteTakingHelperTest, LaunchChromeApp) {
static_cast<int>(LaunchResult::CHROME_SUCCESS), 1);
}
-TEST_F(NoteTakingHelperTest, FallBackIfPreferredAppUnavailable) {
+TEST_P(NoteTakingHelperTest, FallBackIfPreferredAppUnavailable) {
Init(ENABLE_PALETTE);
auto prod_extension =
CreateExtension(NoteTakingHelper::kProdKeepExtensionId, "prod");
@@ -467,25 +476,27 @@ TEST_F(NoteTakingHelperTest, FallBackIfPreferredAppUnavailable) {
static_cast<int>(LaunchResult::CHROME_SUCCESS), 1);
}
-TEST_F(NoteTakingHelperTest, ArcInitiallyDisabled) {
+TEST_P(NoteTakingHelperTest, PlayInitiallyDisabled) {
Init(ENABLE_PALETTE);
- EXPECT_FALSE(helper()->android_enabled());
+ EXPECT_FALSE(helper()->play_enabled());
EXPECT_FALSE(helper()->android_apps_received());
-
- // When ARC is enabled, the helper's members should be updated accordingly.
+ // TODO(victorhsieh): Imeplement opt-in.
+ if (IsPersistentArc())
+ return;
+ // When Play is enabled, the helper's members should be updated accordingly.
profile()->GetPrefs()->SetBoolean(prefs::kArcEnabled, true);
- EXPECT_TRUE(helper()->android_enabled());
+ EXPECT_TRUE(helper()->play_enabled());
EXPECT_FALSE(helper()->android_apps_received());
// After the callback to receive intent handlers has run, the "apps received"
// member should be updated (even if there aren't any apps).
helper()->OnIntentFiltersUpdated();
base::RunLoop().RunUntilIdle();
- EXPECT_TRUE(helper()->android_enabled());
+ EXPECT_TRUE(helper()->play_enabled());
EXPECT_TRUE(helper()->android_apps_received());
}
-TEST_F(NoteTakingHelperTest, ListAndroidApps) {
+TEST_P(NoteTakingHelperTest, ListAndroidApps) {
// Add two Android apps.
std::vector<IntentHandlerInfoPtr> handlers;
const std::string kName1 = "App 1";
@@ -499,14 +510,14 @@ TEST_F(NoteTakingHelperTest, ListAndroidApps) {
// NoteTakingHelper should make an async request for Android apps when
// constructed.
- Init(ENABLE_PALETTE | ENABLE_ARC);
- EXPECT_TRUE(helper()->android_enabled());
+ Init(ENABLE_PALETTE | ENABLE_PLAY);
+ EXPECT_TRUE(helper()->play_enabled());
EXPECT_FALSE(helper()->android_apps_received());
EXPECT_TRUE(helper()->GetAvailableApps(profile()).empty());
// The apps should be listed after the callback has had a chance to run.
base::RunLoop().RunUntilIdle();
- EXPECT_TRUE(helper()->android_enabled());
+ EXPECT_TRUE(helper()->play_enabled());
EXPECT_TRUE(helper()->android_apps_received());
EXPECT_TRUE(helper()->IsAppAvailable(profile()));
std::vector<NoteTakingAppInfo> apps = helper()->GetAvailableApps(profile());
@@ -514,22 +525,26 @@ TEST_F(NoteTakingHelperTest, ListAndroidApps) {
EXPECT_EQ(GetAppString(kPackage1, kName1, false), GetAppString(apps[0]));
EXPECT_EQ(GetAppString(kPackage2, kName2, false), GetAppString(apps[1]));
- // Disable ARC and check that the apps are no longer returned.
+ // TODO(victorhsieh): Opt-out on Persistent ARC is special. Skip until
+ // implemented.
+ if (IsPersistentArc())
+ return;
+ // Disable Play and check that the apps are no longer returned.
profile()->GetPrefs()->SetBoolean(prefs::kArcEnabled, false);
- EXPECT_FALSE(helper()->android_enabled());
+ EXPECT_FALSE(helper()->play_enabled());
EXPECT_FALSE(helper()->android_apps_received());
EXPECT_FALSE(helper()->IsAppAvailable(profile()));
EXPECT_TRUE(helper()->GetAvailableApps(profile()).empty());
}
-TEST_F(NoteTakingHelperTest, LaunchAndroidApp) {
+TEST_P(NoteTakingHelperTest, LaunchAndroidApp) {
const std::string kPackage1 = "org.chromium.package1";
std::vector<IntentHandlerInfoPtr> handlers;
handlers.emplace_back(CreateIntentHandlerInfo("App 1", kPackage1));
intent_helper_.SetIntentHandlers(NoteTakingHelper::kIntentAction,
std::move(handlers));
- Init(ENABLE_PALETTE | ENABLE_ARC);
+ Init(ENABLE_PALETTE | ENABLE_PLAY);
base::RunLoop().RunUntilIdle();
ASSERT_TRUE(helper()->IsAppAvailable(profile()));
@@ -572,14 +587,14 @@ TEST_F(NoteTakingHelperTest, LaunchAndroidApp) {
NoteTakingHelper::kDefaultLaunchResultHistogramName, 0);
}
-TEST_F(NoteTakingHelperTest, LaunchAndroidAppWithPath) {
+TEST_P(NoteTakingHelperTest, LaunchAndroidAppWithPath) {
const std::string kPackage = "org.chromium.package";
std::vector<IntentHandlerInfoPtr> handlers;
handlers.emplace_back(CreateIntentHandlerInfo("App", kPackage));
intent_helper_.SetIntentHandlers(NoteTakingHelper::kIntentAction,
std::move(handlers));
- Init(ENABLE_PALETTE | ENABLE_ARC);
+ Init(ENABLE_PALETTE | ENABLE_PLAY);
base::RunLoop().RunUntilIdle();
ASSERT_TRUE(helper()->IsAppAvailable(profile()));
@@ -615,8 +630,8 @@ TEST_F(NoteTakingHelperTest, LaunchAndroidAppWithPath) {
static_cast<int>(LaunchResult::ANDROID_FAILED_TO_CONVERT_PATH), 1);
}
-TEST_F(NoteTakingHelperTest, NoAppsAvailable) {
- Init(ENABLE_PALETTE | ENABLE_ARC);
+TEST_P(NoteTakingHelperTest, NoAppsAvailable) {
+ Init(ENABLE_PALETTE | ENABLE_PLAY);
// When no note-taking apps are installed, the histograms should just be
// updated.
@@ -630,15 +645,20 @@ TEST_F(NoteTakingHelperTest, NoAppsAvailable) {
static_cast<int>(LaunchResult::NO_APPS_AVAILABLE), 1);
}
-TEST_F(NoteTakingHelperTest, NotifyObserverAboutAndroidApps) {
- Init(ENABLE_PALETTE | ENABLE_ARC);
+TEST_P(NoteTakingHelperTest, NotifyObserverAboutAndroidApps) {
+ Init(ENABLE_PALETTE | ENABLE_PLAY);
TestObserver observer;
// Let the app-fetching callback run and check that the observer is notified.
base::RunLoop().RunUntilIdle();
EXPECT_EQ(1, observer.num_updates());
- // Disabling and enabling ARC should also notify the observer (and enabling
+ // TODO(victorhsieh): Opt-out on Persistent ARC is special. Skip until
+ // implemented.
+ if (IsPersistentArc())
+ return;
+
+ // Disabling and enabling Play should also notify the observer (and enabling
// should request apps again).
profile()->GetPrefs()->SetBoolean(prefs::kArcEnabled, false);
EXPECT_EQ(2, observer.num_updates());
@@ -655,7 +675,7 @@ TEST_F(NoteTakingHelperTest, NotifyObserverAboutAndroidApps) {
EXPECT_EQ(4, observer.num_updates());
}
-TEST_F(NoteTakingHelperTest, NotifyObserverAboutChromeApps) {
+TEST_P(NoteTakingHelperTest, NotifyObserverAboutChromeApps) {
Init(ENABLE_PALETTE);
TestObserver observer;
ASSERT_EQ(0, observer.num_updates());

Powered by Google App Engine
This is Rietveld 408576698