OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/policy/enterprise_install_attributes.h" | 5 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
12 #include "chrome/browser/chromeos/cros/cryptohome_library.h" | |
13 #include "chrome/browser/chromeos/policy/proto/install_attributes.pb.h" | 12 #include "chrome/browser/chromeos/policy/proto/install_attributes.pb.h" |
| 13 #include "chromeos/cryptohome/cryptohome_library.h" |
14 #include "chromeos/dbus/cryptohome_client.h" | 14 #include "chromeos/dbus/cryptohome_client.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 | 16 |
17 namespace policy { | 17 namespace policy { |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 void CopyLockResult(base::RunLoop* loop, | 21 void CopyLockResult(base::RunLoop* loop, |
22 EnterpriseInstallAttributes::LockResult* out, | 22 EnterpriseInstallAttributes::LockResult* out, |
23 EnterpriseInstallAttributes::LockResult result) { | 23 EnterpriseInstallAttributes::LockResult result) { |
24 *out = result; | 24 *out = result; |
25 loop->Quit(); | 25 loop->Quit(); |
26 } | 26 } |
27 | 27 |
28 } // namespace | 28 } // namespace |
29 | 29 |
30 static const char kTestUser[] = "test@example.com"; | 30 static const char kTestUser[] = "test@example.com"; |
31 static const char kTestDomain[] = "example.com"; | 31 static const char kTestDomain[] = "example.com"; |
32 static const char kTestDeviceId[] = "133750519"; | 32 static const char kTestDeviceId[] = "133750519"; |
33 | 33 |
34 class EnterpriseInstallAttributesTest : public testing::Test { | 34 class EnterpriseInstallAttributesTest : public testing::Test { |
35 protected: | 35 protected: |
36 EnterpriseInstallAttributesTest() | 36 EnterpriseInstallAttributesTest() |
37 : cryptohome_(chromeos::CryptohomeLibrary::GetImpl(true)), | 37 : cryptohome_(chromeos::CryptohomeLibrary::GetTestImpl()), |
38 stub_cryptohome_client_(chromeos::CryptohomeClient::Create( | 38 stub_cryptohome_client_(chromeos::CryptohomeClient::Create( |
39 chromeos::STUB_DBUS_CLIENT_IMPLEMENTATION, NULL)), | 39 chromeos::STUB_DBUS_CLIENT_IMPLEMENTATION, NULL)), |
40 install_attributes_(cryptohome_.get(), stub_cryptohome_client_.get()) {} | 40 install_attributes_(cryptohome_.get(), stub_cryptohome_client_.get()) {} |
41 | 41 |
42 virtual void SetUp() OVERRIDE { | 42 virtual void SetUp() OVERRIDE { |
43 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 43 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
44 } | 44 } |
45 | 45 |
46 base::FilePath GetTempPath() const { | 46 base::FilePath GetTempPath() const { |
47 return temp_dir_.path().Append("install_attrs_test"); | 47 return temp_dir_.path().Append("install_attrs_test"); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 ASSERT_EQ(static_cast<int>(blob.size()), | 201 ASSERT_EQ(static_cast<int>(blob.size()), |
202 file_util::WriteFile(GetTempPath(), blob.c_str(), blob.size())); | 202 file_util::WriteFile(GetTempPath(), blob.c_str(), blob.size())); |
203 install_attributes_.ReadCacheFile(GetTempPath()); | 203 install_attributes_.ReadCacheFile(GetTempPath()); |
204 EXPECT_EQ(DEVICE_MODE_ENTERPRISE, install_attributes_.GetMode()); | 204 EXPECT_EQ(DEVICE_MODE_ENTERPRISE, install_attributes_.GetMode()); |
205 EXPECT_EQ(kTestDomain, install_attributes_.GetDomain()); | 205 EXPECT_EQ(kTestDomain, install_attributes_.GetDomain()); |
206 EXPECT_EQ(kTestUser, install_attributes_.GetRegistrationUser()); | 206 EXPECT_EQ(kTestUser, install_attributes_.GetRegistrationUser()); |
207 EXPECT_EQ("", install_attributes_.GetDeviceId()); | 207 EXPECT_EQ("", install_attributes_.GetDeviceId()); |
208 } | 208 } |
209 | 209 |
210 } // namespace policy | 210 } // namespace policy |
OLD | NEW |