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

Unified Diff: components/arc/arc_util_unittest.cc

Issue 2885933003: arc: Consolidate IsArcAllowedForUser logic (Closed)
Patch Set: fix typo Created 3 years, 7 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
« components/arc/arc_util.cc ('K') | « components/arc/arc_util.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/arc/arc_util_unittest.cc
diff --git a/components/arc/arc_util_unittest.cc b/components/arc/arc_util_unittest.cc
index a39c92bbc15000dd76a49158bd464bbb1174fa52..0b67c09ba37fb44e039bb8887759407ce9e1b75f 100644
--- a/components/arc/arc_util_unittest.cc
+++ b/components/arc/arc_util_unittest.cc
@@ -11,6 +11,8 @@
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/test/scoped_feature_list.h"
+#include "components/signin/core/account_id/account_id.h"
+#include "components/user_manager/user.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace arc {
@@ -35,6 +37,23 @@ class ScopedArcFeature {
DISALLOW_COPY_AND_ASSIGN(ScopedArcFeature);
};
+// Fake user that can be created with a specified type.
+class FakeUser : public user_manager::User {
+ public:
+ explicit FakeUser(user_manager::UserType user_type)
+ : User(AccountId::FromUserEmail("user@test.com")),
+ user_type_(user_type) {}
+ ~FakeUser() override = default;
+
+ // user_manager::User:
+ user_manager::UserType GetType() const override { return user_type_; }
+
+ private:
+ const user_manager::UserType user_type_;
+
+ DISALLOW_COPY_AND_ASSIGN(FakeUser);
+};
+
using ArcUtilTest = testing::Test;
TEST_F(ArcUtilTest, IsArcAvailable_None) {
@@ -163,5 +182,35 @@ TEST_F(ArcUtilTest, IsArcOptInVerificationDisabled) {
EXPECT_TRUE(IsArcOptInVerificationDisabled());
}
+TEST_F(ArcUtilTest, IsArcAllowedForUser) {
+ struct {
+ user_manager::UserType user_type;
+ bool expected_allowed;
+ } const kTestCases[] = {
+ {user_manager::USER_TYPE_REGULAR, true},
+ {user_manager::USER_TYPE_GUEST, false},
+ {user_manager::USER_TYPE_PUBLIC_ACCOUNT, false},
+ {user_manager::USER_TYPE_SUPERVISED, false},
+ {user_manager::USER_TYPE_KIOSK_APP, false},
+ {user_manager::USER_TYPE_CHILD, true},
+ {user_manager::USER_TYPE_ARC_KIOSK_APP, false},
+ {user_manager::USER_TYPE_ACTIVE_DIRECTORY, false},
+ };
+ for (const auto& test_case : kTestCases) {
+ const FakeUser user(test_case.user_type);
+ EXPECT_EQ(test_case.expected_allowed, IsArcAllowedForUser(&user))
+ << "User type=" << test_case.user_type;
+ }
+
+ // Active directory users are allowed when ARC is supported for active
+ // directory managed devices.
+ auto* command_line = base::CommandLine::ForCurrentProcess();
+ command_line->InitFromArgv(
+ {"", "--arc-availability=officially-supported-with-active-directory"});
+ const FakeUser active_directory_user(
+ user_manager::USER_TYPE_ACTIVE_DIRECTORY);
+ EXPECT_TRUE(IsArcAllowedForUser(&active_directory_user));
+}
+
} // namespace
} // namespace arc
« components/arc/arc_util.cc ('K') | « components/arc/arc_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698