Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: components/policy/core/common/cloud/resource_cache_unittest.cc

Issue 2317123002: c/browser, c/common, components O-P: Change ScopedTempDir::path() to GetPath() (Closed)
Patch Set: Just rebased Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "components/policy/core/common/cloud/resource_cache.h" 5 #include "components/policy/core/common/cloud/resource_cache.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/test/test_simple_task_runner.h" 10 #include "base/test/test_simple_task_runner.h"
(...skipping 17 matching lines...) Expand all
28 28
29 bool Matches(const std::string& expected, const std::string& subkey) { 29 bool Matches(const std::string& expected, const std::string& subkey) {
30 return subkey == expected; 30 return subkey == expected;
31 } 31 }
32 32
33 } // namespace 33 } // namespace
34 34
35 TEST(ResourceCacheTest, StoreAndLoad) { 35 TEST(ResourceCacheTest, StoreAndLoad) {
36 base::ScopedTempDir temp_dir; 36 base::ScopedTempDir temp_dir;
37 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 37 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
38 ResourceCache cache(temp_dir.path(), 38 ResourceCache cache(temp_dir.GetPath(),
39 make_scoped_refptr(new base::TestSimpleTaskRunner)); 39 make_scoped_refptr(new base::TestSimpleTaskRunner));
40 40
41 // No data initially. 41 // No data initially.
42 std::string data; 42 std::string data;
43 EXPECT_FALSE(cache.Load(kKey1, kSubA, &data)); 43 EXPECT_FALSE(cache.Load(kKey1, kSubA, &data));
44 44
45 // Store some data and load it. 45 // Store some data and load it.
46 EXPECT_TRUE(cache.Store(kKey1, kSubA, kData0)); 46 EXPECT_TRUE(cache.Store(kKey1, kSubA, kData0));
47 EXPECT_TRUE(cache.Load(kKey1, kSubA, &data)); 47 EXPECT_TRUE(cache.Load(kKey1, kSubA, &data));
48 EXPECT_EQ(kData0, data); 48 EXPECT_EQ(kData0, data);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 // The third key is unaffected. 110 // The third key is unaffected.
111 cache.LoadAllSubkeys(kKey3, &contents); 111 cache.LoadAllSubkeys(kKey3, &contents);
112 EXPECT_EQ(2u, contents.size()); 112 EXPECT_EQ(2u, contents.size());
113 EXPECT_EQ(kData0, contents[kSubA]); 113 EXPECT_EQ(kData0, contents[kSubA]);
114 EXPECT_EQ(kData1, contents[kSubB]); 114 EXPECT_EQ(kData1, contents[kSubB]);
115 } 115 }
116 116
117 TEST(ResourceCacheTest, FilterSubkeys) { 117 TEST(ResourceCacheTest, FilterSubkeys) {
118 base::ScopedTempDir temp_dir; 118 base::ScopedTempDir temp_dir;
119 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 119 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
120 ResourceCache cache(temp_dir.path(), 120 ResourceCache cache(temp_dir.GetPath(),
121 make_scoped_refptr(new base::TestSimpleTaskRunner)); 121 make_scoped_refptr(new base::TestSimpleTaskRunner));
122 122
123 // Store some data. 123 // Store some data.
124 EXPECT_TRUE(cache.Store(kKey1, kSubA, kData0)); 124 EXPECT_TRUE(cache.Store(kKey1, kSubA, kData0));
125 EXPECT_TRUE(cache.Store(kKey1, kSubB, kData1)); 125 EXPECT_TRUE(cache.Store(kKey1, kSubB, kData1));
126 EXPECT_TRUE(cache.Store(kKey1, kSubC, kData0)); 126 EXPECT_TRUE(cache.Store(kKey1, kSubC, kData0));
127 EXPECT_TRUE(cache.Store(kKey2, kSubA, kData0)); 127 EXPECT_TRUE(cache.Store(kKey2, kSubA, kData0));
128 EXPECT_TRUE(cache.Store(kKey2, kSubB, kData1)); 128 EXPECT_TRUE(cache.Store(kKey2, kSubB, kData1));
129 EXPECT_TRUE(cache.Store(kKey3, kSubA, kData0)); 129 EXPECT_TRUE(cache.Store(kKey3, kSubA, kData0));
130 EXPECT_TRUE(cache.Store(kKey3, kSubB, kData1)); 130 EXPECT_TRUE(cache.Store(kKey3, kSubB, kData1));
(...skipping 16 matching lines...) Expand all
147 EXPECT_EQ(kData0, contents[kSubC]); 147 EXPECT_EQ(kData0, contents[kSubC]);
148 148
149 // Other keys weren't affected. 149 // Other keys weren't affected.
150 cache.LoadAllSubkeys(kKey2, &contents); 150 cache.LoadAllSubkeys(kKey2, &contents);
151 EXPECT_EQ(2u, contents.size()); 151 EXPECT_EQ(2u, contents.size());
152 cache.LoadAllSubkeys(kKey3, &contents); 152 cache.LoadAllSubkeys(kKey3, &contents);
153 EXPECT_EQ(2u, contents.size()); 153 EXPECT_EQ(2u, contents.size());
154 } 154 }
155 155
156 } // namespace policy 156 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698