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

Unified Diff: chrome/browser/policy/resource_cache_unittest.cc

Issue 12189011: Split up chrome/browser/policy subdirectory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase, add chrome/browser/chromeos/policy/OWNERS Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/policy/resource_cache.cc ('k') | chrome/browser/policy/test/local_policy_test_server.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/policy/resource_cache_unittest.cc
diff --git a/chrome/browser/policy/resource_cache_unittest.cc b/chrome/browser/policy/resource_cache_unittest.cc
deleted file mode 100644
index a6fd008e871ca88ee99bc252b5372d56db297b56..0000000000000000000000000000000000000000
--- a/chrome/browser/policy/resource_cache_unittest.cc
+++ /dev/null
@@ -1,86 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/policy/resource_cache.h"
-
-#include "base/basictypes.h"
-#include "base/files/scoped_temp_dir.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace policy {
-
-namespace {
-
-const char kKey[] = "key";
-const char kAnotherKey[] = "anotherkey";
-const char kSubA[] = "a";
-const char kSubB[] = "bb";
-const char kSubC[] = "ccc";
-const char kSubD[] = "dddd";
-const char kSubE[] = "eeeee";
-
-const char kData0[] = "{ \"key\": \"value\" }";
-const char kData1[] = "{}";
-
-} // namespace
-
-TEST(ResourceCacheTest, StoreAndLoad) {
- base::ScopedTempDir temp_dir;
- ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
- ResourceCache cache(temp_dir.path().AppendASCII("db"));
-
- // No data initially.
- std::string data;
- EXPECT_FALSE(cache.Load(kKey, kSubA, &data));
-
- // Store some data and load it.
- EXPECT_TRUE(cache.Store(kKey, kSubA, kData0));
- EXPECT_TRUE(cache.Load(kKey, kSubA, &data));
- EXPECT_EQ(kData0, data);
-
- // Store more data in another subkey.
- EXPECT_TRUE(cache.Store(kKey, kSubB, kData1));
-
- // Write subkeys to another key.
- EXPECT_TRUE(cache.Store(kAnotherKey, kSubA, kData0));
- EXPECT_TRUE(cache.Store(kAnotherKey, kSubB, kData1));
-
- // Enumerate all the keys.
- std::map<std::string, std::string> contents;
- cache.LoadAllSubkeys(kKey, &contents);
- EXPECT_EQ(2u, contents.size());
- EXPECT_EQ(kData0, contents[kSubA]);
- EXPECT_EQ(kData1, contents[kSubB]);
-
- // Store more keys.
- EXPECT_TRUE(cache.Store(kKey, kSubC, kData1));
- EXPECT_TRUE(cache.Store(kKey, kSubD, kData1));
- EXPECT_TRUE(cache.Store(kKey, kSubE, kData1));
-
- // Now purge some of them.
- std::set<std::string> keep;
- keep.insert(kSubB);
- keep.insert(kSubD);
- cache.PurgeOtherSubkeys(kKey, keep);
-
- // Enumerate all the remaining keys.
- cache.LoadAllSubkeys(kKey, &contents);
- EXPECT_EQ(2u, contents.size());
- EXPECT_EQ(kData1, contents[kSubB]);
- EXPECT_EQ(kData1, contents[kSubD]);
-
- // Delete keys directly.
- cache.Delete(kKey, kSubB);
- cache.Delete(kKey, kSubD);
- cache.LoadAllSubkeys(kKey, &contents);
- EXPECT_EQ(0u, contents.size());
-
- // The other key was not affected.
- cache.LoadAllSubkeys(kAnotherKey, &contents);
- EXPECT_EQ(2u, contents.size());
- EXPECT_EQ(kData0, contents[kSubA]);
- EXPECT_EQ(kData1, contents[kSubB]);
-}
-
-} // namespace policy
« no previous file with comments | « chrome/browser/policy/resource_cache.cc ('k') | chrome/browser/policy/test/local_policy_test_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698