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