| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "chrome/browser/chromeos/policy/affiliation_test_helper.h" | 9 #include "chrome/browser/chromeos/policy/affiliation_test_helper.h" |
| 10 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" | 10 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" |
| 11 #include "chromeos/dbus/dbus_thread_manager.h" | 11 #include "chromeos/dbus/dbus_thread_manager.h" |
| 12 #include "chromeos/dbus/fake_session_manager_client.h" | 12 #include "chromeos/dbus/fake_session_manager_client.h" |
| 13 #include "chromeos/dbus/session_manager_client.h" | 13 #include "chromeos/dbus/session_manager_client.h" |
| 14 #include "components/policy/core/common/cloud/device_management_service.h" |
| 14 #include "components/user_manager/user.h" | 15 #include "components/user_manager/user.h" |
| 15 #include "components/user_manager/user_manager.h" | 16 #include "components/user_manager/user_manager.h" |
| 16 #include "content/public/test/test_utils.h" | 17 #include "content/public/test/test_utils.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 19 |
| 19 namespace policy { | 20 namespace policy { |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 const char kAffiliatedUser[] = "affiliated-user@example.com"; | 24 const char kAffiliatedUser[] = "affiliated-user@example.com"; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 | 65 |
| 65 std::set<std::string> user_affiliation_ids; | 66 std::set<std::string> user_affiliation_ids; |
| 66 if (GetParam().affiliated_) { | 67 if (GetParam().affiliated_) { |
| 67 user_affiliation_ids.insert(kAffiliationID); | 68 user_affiliation_ids.insert(kAffiliationID); |
| 68 } else { | 69 } else { |
| 69 user_affiliation_ids.insert(kAnotherAffiliationID); | 70 user_affiliation_ids.insert(kAnotherAffiliationID); |
| 70 } | 71 } |
| 71 affiliation_test_helper::SetUserAffiliationIDs( | 72 affiliation_test_helper::SetUserAffiliationIDs( |
| 72 &user_policy, fake_session_manager_client, kAffiliatedUser, | 73 &user_policy, fake_session_manager_client, kAffiliatedUser, |
| 73 user_affiliation_ids); | 74 user_affiliation_ids); |
| 75 |
| 76 // Set retry delay to prevent timeouts. |
| 77 policy::DeviceManagementService::SetRetryDelayForTesting(0); |
| 74 } | 78 } |
| 75 | 79 |
| 76 private: | 80 private: |
| 77 DISALLOW_COPY_AND_ASSIGN(UserAffiliationBrowserTest); | 81 DISALLOW_COPY_AND_ASSIGN(UserAffiliationBrowserTest); |
| 78 }; | 82 }; |
| 79 | 83 |
| 80 IN_PROC_BROWSER_TEST_P(UserAffiliationBrowserTest, PRE_Affiliated) { | 84 IN_PROC_BROWSER_TEST_P(UserAffiliationBrowserTest, PRE_Affiliated) { |
| 81 affiliation_test_helper::PreLoginUser(kAffiliatedUser); | 85 affiliation_test_helper::PreLoginUser(kAffiliatedUser); |
| 82 } | 86 } |
| 83 | 87 |
| 84 IN_PROC_BROWSER_TEST_P(UserAffiliationBrowserTest, Affiliated) { | 88 IN_PROC_BROWSER_TEST_P(UserAffiliationBrowserTest, Affiliated) { |
| 85 affiliation_test_helper::LoginUser(kAffiliatedUser); | 89 affiliation_test_helper::LoginUser(kAffiliatedUser); |
| 86 EXPECT_EQ(GetParam().affiliated_, | 90 EXPECT_EQ(GetParam().affiliated_, |
| 87 user_manager::UserManager::Get() | 91 user_manager::UserManager::Get() |
| 88 ->FindUser(AccountId::FromUserEmail(kAffiliatedUser)) | 92 ->FindUser(AccountId::FromUserEmail(kAffiliatedUser)) |
| 89 ->IsAffiliated()); | 93 ->IsAffiliated()); |
| 90 } | 94 } |
| 91 | 95 |
| 92 INSTANTIATE_TEST_CASE_P(AffiliationCheck, | 96 INSTANTIATE_TEST_CASE_P(AffiliationCheck, |
| 93 UserAffiliationBrowserTest, | 97 UserAffiliationBrowserTest, |
| 94 ::testing::Values(Params(true), Params(false))); | 98 ::testing::Values(Params(true), Params(false))); |
| 95 | 99 |
| 96 } // namespace policy | 100 } // namespace policy |
| OLD | NEW |