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" |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 EXPECT_EQ(DEVICE_MODE_CONSUMER, install_attributes_.GetMode()); | 190 EXPECT_EQ(DEVICE_MODE_CONSUMER, install_attributes_.GetMode()); |
191 } | 191 } |
192 | 192 |
193 TEST_F(EnterpriseInstallAttributesTest, ConsumerKioskDevice) { | 193 TEST_F(EnterpriseInstallAttributesTest, ConsumerKioskDevice) { |
194 install_attributes_.ReadCacheFile(GetTempPath()); | 194 install_attributes_.ReadCacheFile(GetTempPath()); |
195 EXPECT_EQ(DEVICE_MODE_PENDING, install_attributes_.GetMode()); | 195 EXPECT_EQ(DEVICE_MODE_PENDING, install_attributes_.GetMode()); |
196 // Lock the attributes for consumer kiosk. | 196 // Lock the attributes for consumer kiosk. |
197 ASSERT_EQ(EnterpriseInstallAttributes::LOCK_SUCCESS, | 197 ASSERT_EQ(EnterpriseInstallAttributes::LOCK_SUCCESS, |
198 LockDeviceAndWaitForResult( | 198 LockDeviceAndWaitForResult( |
199 std::string(), | 199 std::string(), |
200 DEVICE_MODE_CONSUMER_KIOSK, | 200 DEVICE_MODE_CONSUMER_KIOSK_AUTOLAUNCH, |
201 std::string())); | 201 std::string())); |
202 | 202 |
203 ASSERT_FALSE(cryptohome_util::InstallAttributesIsFirstInstall()); | 203 ASSERT_FALSE(cryptohome_util::InstallAttributesIsFirstInstall()); |
204 EXPECT_EQ(DEVICE_MODE_CONSUMER_KIOSK, install_attributes_.GetMode()); | 204 EXPECT_EQ(DEVICE_MODE_CONSUMER_KIOSK_AUTOLAUNCH, |
205 ASSERT_TRUE(install_attributes_.IsConsumerKioskDevice()); | 205 install_attributes_.GetMode()); |
| 206 ASSERT_TRUE(install_attributes_.IsConsumerKioskDeviceWithAutoLaunch()); |
206 } | 207 } |
207 | 208 |
208 TEST_F(EnterpriseInstallAttributesTest, DeviceLockedFromOlderVersion) { | 209 TEST_F(EnterpriseInstallAttributesTest, DeviceLockedFromOlderVersion) { |
209 install_attributes_.ReadCacheFile(GetTempPath()); | 210 install_attributes_.ReadCacheFile(GetTempPath()); |
210 EXPECT_EQ(DEVICE_MODE_PENDING, install_attributes_.GetMode()); | 211 EXPECT_EQ(DEVICE_MODE_PENDING, install_attributes_.GetMode()); |
211 // Lock the attributes as if it was done from older Chrome version. | 212 // Lock the attributes as if it was done from older Chrome version. |
212 ASSERT_TRUE(cryptohome_util::InstallAttributesSet( | 213 ASSERT_TRUE(cryptohome_util::InstallAttributesSet( |
213 EnterpriseInstallAttributes::kAttrEnterpriseOwned, "true")); | 214 EnterpriseInstallAttributes::kAttrEnterpriseOwned, "true")); |
214 ASSERT_TRUE(cryptohome_util::InstallAttributesSet( | 215 ASSERT_TRUE(cryptohome_util::InstallAttributesSet( |
215 EnterpriseInstallAttributes::kAttrEnterpriseUser, kTestUser)); | 216 EnterpriseInstallAttributes::kAttrEnterpriseUser, kTestUser)); |
(...skipping 26 matching lines...) Expand all Loading... |
242 } | 243 } |
243 | 244 |
244 TEST_F(EnterpriseInstallAttributesTest, ReadCacheFileForConsumerKiosk) { | 245 TEST_F(EnterpriseInstallAttributesTest, ReadCacheFileForConsumerKiosk) { |
245 cryptohome::SerializedInstallAttributes install_attrs_proto; | 246 cryptohome::SerializedInstallAttributes install_attrs_proto; |
246 SetAttribute(&install_attrs_proto, | 247 SetAttribute(&install_attrs_proto, |
247 EnterpriseInstallAttributes::kAttrConsumerKioskEnabled, "true"); | 248 EnterpriseInstallAttributes::kAttrConsumerKioskEnabled, "true"); |
248 const std::string blob(install_attrs_proto.SerializeAsString()); | 249 const std::string blob(install_attrs_proto.SerializeAsString()); |
249 ASSERT_EQ(static_cast<int>(blob.size()), | 250 ASSERT_EQ(static_cast<int>(blob.size()), |
250 file_util::WriteFile(GetTempPath(), blob.c_str(), blob.size())); | 251 file_util::WriteFile(GetTempPath(), blob.c_str(), blob.size())); |
251 install_attributes_.ReadCacheFile(GetTempPath()); | 252 install_attributes_.ReadCacheFile(GetTempPath()); |
252 EXPECT_EQ(DEVICE_MODE_CONSUMER_KIOSK, install_attributes_.GetMode()); | 253 EXPECT_EQ(DEVICE_MODE_CONSUMER_KIOSK_AUTOLAUNCH, |
| 254 install_attributes_.GetMode()); |
253 EXPECT_EQ("", install_attributes_.GetDomain()); | 255 EXPECT_EQ("", install_attributes_.GetDomain()); |
254 EXPECT_EQ("", install_attributes_.GetRegistrationUser()); | 256 EXPECT_EQ("", install_attributes_.GetRegistrationUser()); |
255 EXPECT_EQ("", install_attributes_.GetDeviceId()); | 257 EXPECT_EQ("", install_attributes_.GetDeviceId()); |
256 } | 258 } |
257 | 259 |
258 } // namespace policy | 260 } // namespace policy |
OLD | NEW |