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

Side by Side Diff: chrome/browser/policy/cloud/cloud_external_data_store_unittest.cc

Issue 23868021: Prepare ExternalPolicyDataUpdater and ResourceCache for blocking pool (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Re-uploading due to rietveld flake. Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "chrome/browser/policy/cloud/cloud_external_data_store.h" 5 #include "chrome/browser/policy/cloud/cloud_external_data_store.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
10 #include "base/sha1.h" 11 #include "base/sha1.h"
12 #include "base/test/test_simple_task_runner.h"
11 #include "chrome/browser/policy/cloud/resource_cache.h" 13 #include "chrome/browser/policy/cloud/resource_cache.h"
12 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
13 15
14 namespace policy { 16 namespace policy {
15 17
16 namespace { 18 namespace {
17 19
18 const char kKey1[] = "Key 1"; 20 const char kKey1[] = "Key 1";
19 const char kKey2[] = "Key 2"; 21 const char kKey2[] = "Key 2";
20 const char kPolicy1[] = "Test policy 1"; 22 const char kPolicy1[] = "Test policy 1";
(...skipping 21 matching lines...) Expand all
42 DISALLOW_COPY_AND_ASSIGN(CouldExternalDataStoreTest); 44 DISALLOW_COPY_AND_ASSIGN(CouldExternalDataStoreTest);
43 }; 45 };
44 46
45 CouldExternalDataStoreTest::CouldExternalDataStoreTest() 47 CouldExternalDataStoreTest::CouldExternalDataStoreTest()
46 : kData1Hash(base::SHA1HashString(kData1)), 48 : kData1Hash(base::SHA1HashString(kData1)),
47 kData2Hash(base::SHA1HashString(kData2)) { 49 kData2Hash(base::SHA1HashString(kData2)) {
48 } 50 }
49 51
50 void CouldExternalDataStoreTest::SetUp() { 52 void CouldExternalDataStoreTest::SetUp() {
51 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 53 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
52 resource_cache_.reset(new ResourceCache(temp_dir_.path())); 54 resource_cache_.reset(new ResourceCache(
55 temp_dir_.path(),
56 make_scoped_refptr(new base::TestSimpleTaskRunner)));
53 } 57 }
54 58
55 TEST_F(CouldExternalDataStoreTest, StoreAndLoad) { 59 TEST_F(CouldExternalDataStoreTest, StoreAndLoad) {
56 // Write an entry to a store. 60 // Write an entry to a store.
57 CloudExternalDataStore store(kKey1, resource_cache_.get()); 61 CloudExternalDataStore store(kKey1, resource_cache_.get());
58 EXPECT_TRUE(store.Store(kPolicy1, kData1Hash, kData1)); 62 EXPECT_TRUE(store.Store(kPolicy1, kData1Hash, kData1));
59 63
60 // Check that loading and verifying the entry against an invalid hash fails. 64 // Check that loading and verifying the entry against an invalid hash fails.
61 std::string data; 65 std::string data;
62 EXPECT_FALSE(store.Load(kPolicy1, kData2Hash, kMaxSize, &data)); 66 EXPECT_FALSE(store.Load(kPolicy1, kData2Hash, kMaxSize, &data));
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 EXPECT_TRUE(contents.empty()); 190 EXPECT_TRUE(contents.empty());
187 191
188 // Check that the part of the resource cache backing the second store is 192 // Check that the part of the resource cache backing the second store is
189 // unaffected. 193 // unaffected.
190 resource_cache_->LoadAllSubkeys(kKey2, &contents); 194 resource_cache_->LoadAllSubkeys(kKey2, &contents);
191 ASSERT_EQ(1u, contents.size()); 195 ASSERT_EQ(1u, contents.size());
192 EXPECT_EQ(kData2, contents.begin()->second); 196 EXPECT_EQ(kData2, contents.begin()->second);
193 } 197 }
194 198
195 } // namespace policy 199 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698