OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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/login/signed_settings_temp_storage.h" | 5 #include "chrome/browser/chromeos/login/signed_settings_temp_storage.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 #include <map> | 9 #include <map> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/scoped_temp_dir.h" | 14 #include "base/scoped_temp_dir.h" |
15 #include "chrome/common/logging_chrome.h" | 15 #include "chrome/common/logging_chrome.h" |
16 #include "chrome/test/base/testing_pref_service.h" | 16 #include "chrome/test/base/testing_pref_service.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 | 18 |
19 namespace chromeos { | 19 namespace chromeos { |
20 | 20 |
21 class SignedSettingsTempStorageTest : public testing::Test { | 21 class SignedSettingsTempStorageTest : public testing::Test { |
22 protected: | 22 protected: |
23 virtual void SetUp() { | 23 virtual void SetUp() { |
24 ref_map_["some_stuff"] = "a=35;code=64"; | 24 ref_map_.Set("some_stuff", base::Value::CreateStringValue("a=35;code=64")); |
25 ref_map_["another_stuff"] = ""; | 25 ref_map_.Set("another_stuff", base::Value::CreateBooleanValue(false)); |
26 ref_map_["name"] = "value"; | 26 ref_map_.Set("name", base::Value::CreateStringValue("value")); |
27 ref_map_["2bc6aa16-e0ea-11df-b13d-18a90520e2e5"] = "512"; | 27 ref_map_.Set("2bc6aa16-e0ea-11df-b13d-18a90520e2e5", |
| 28 base::Value::CreateIntegerValue(512)); |
28 | 29 |
29 SignedSettingsTempStorage::RegisterPrefs(&local_state_); | 30 SignedSettingsTempStorage::RegisterPrefs(&local_state_); |
30 } | 31 } |
31 | 32 |
32 std::map<std::string, std::string> ref_map_; | 33 base::DictionaryValue ref_map_; |
33 TestingPrefService local_state_; | 34 TestingPrefService local_state_; |
34 }; | 35 }; |
35 | 36 |
36 TEST_F(SignedSettingsTempStorageTest, Basic) { | 37 TEST_F(SignedSettingsTempStorageTest, Basic) { |
37 typedef std::map<std::string, std::string>::iterator It; | 38 typedef base::DictionaryValue::key_iterator It; |
38 for (It it = ref_map_.begin(); it != ref_map_.end(); ++it) { | 39 base::Value* value; |
39 EXPECT_TRUE(SignedSettingsTempStorage::Store(it->first, | 40 for (It it = ref_map_.begin_keys(); it != ref_map_.end_keys(); ++it) { |
40 it->second, | 41 ref_map_.Get(*it, &value); |
| 42 EXPECT_TRUE(SignedSettingsTempStorage::Store(*it, *value, |
41 &local_state_)); | 43 &local_state_)); |
42 } | 44 } |
43 for (It it = ref_map_.begin(); it != ref_map_.end(); ++it) { | 45 for (It it = ref_map_.begin_keys(); it != ref_map_.end_keys(); ++it) { |
44 std::string value; | 46 EXPECT_TRUE(SignedSettingsTempStorage::Retrieve(*it, &value, |
45 EXPECT_TRUE(SignedSettingsTempStorage::Retrieve(it->first, &value, | |
46 &local_state_)); | 47 &local_state_)); |
47 EXPECT_EQ(it->second, value); | 48 base::Value* orignal_value; |
| 49 ref_map_.Get(*it, &orignal_value); |
| 50 EXPECT_TRUE(orignal_value->Equals(value)); |
48 } | 51 } |
49 std::string value; | |
50 EXPECT_FALSE(SignedSettingsTempStorage::Retrieve("non-existent tv-series", | 52 EXPECT_FALSE(SignedSettingsTempStorage::Retrieve("non-existent tv-series", |
51 &value, | 53 &value, |
52 &local_state_)); | 54 &local_state_)); |
53 } | 55 } |
54 | 56 |
55 } // namespace chromeos | 57 } // namespace chromeos |
OLD | NEW |