OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/policy/enterprise_install_attributes.h" |
| 6 |
| 7 #include "chrome/browser/chromeos/cros/cryptohome_library.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 |
| 10 namespace policy { |
| 11 |
| 12 static const char kTestUser[] = "test@example.com"; |
| 13 |
| 14 class EnterpriseInstallAttributesTest : public testing::Test { |
| 15 protected: |
| 16 EnterpriseInstallAttributesTest() |
| 17 : cryptohome_(chromeos::CryptohomeLibrary::GetImpl(true)), |
| 18 install_attributes_(cryptohome_.get()) {} |
| 19 |
| 20 scoped_ptr<chromeos::CryptohomeLibrary> cryptohome_; |
| 21 EnterpriseInstallAttributes install_attributes_; |
| 22 }; |
| 23 |
| 24 TEST_F(EnterpriseInstallAttributesTest, Lock) { |
| 25 EXPECT_EQ(EnterpriseInstallAttributes::LOCK_SUCCESS, |
| 26 install_attributes_.LockDevice(kTestUser)); |
| 27 |
| 28 EXPECT_EQ(EnterpriseInstallAttributes::LOCK_SUCCESS, |
| 29 install_attributes_.LockDevice(kTestUser)); |
| 30 EXPECT_EQ(EnterpriseInstallAttributes::LOCK_WRONG_USER, |
| 31 install_attributes_.LockDevice("test1@example.com")); |
| 32 } |
| 33 |
| 34 TEST_F(EnterpriseInstallAttributesTest, IsEnterpriseDevice) { |
| 35 EXPECT_FALSE(install_attributes_.IsEnterpriseDevice()); |
| 36 ASSERT_EQ(EnterpriseInstallAttributes::LOCK_SUCCESS, |
| 37 install_attributes_.LockDevice(kTestUser)); |
| 38 EXPECT_TRUE(install_attributes_.IsEnterpriseDevice()); |
| 39 } |
| 40 |
| 41 TEST_F(EnterpriseInstallAttributesTest, GetDomain) { |
| 42 EXPECT_EQ(std::string(), install_attributes_.GetDomain()); |
| 43 ASSERT_EQ(EnterpriseInstallAttributes::LOCK_SUCCESS, |
| 44 install_attributes_.LockDevice(kTestUser)); |
| 45 EXPECT_EQ("example.com", install_attributes_.GetDomain()); |
| 46 } |
| 47 |
| 48 TEST_F(EnterpriseInstallAttributesTest, GetRegistrationUser) { |
| 49 EXPECT_EQ(std::string(), install_attributes_.GetRegistrationUser()); |
| 50 ASSERT_EQ(EnterpriseInstallAttributes::LOCK_SUCCESS, |
| 51 install_attributes_.LockDevice(kTestUser)); |
| 52 EXPECT_EQ(kTestUser, install_attributes_.GetRegistrationUser()); |
| 53 } |
| 54 |
| 55 } // namespace policy |
OLD | NEW |