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

Side by Side Diff: content/browser/storage_partition_impl_map_unittest.cc

Issue 314293003: [Storage] Normalize storage partition path before garbage collection (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: export StoragePartitionImplMap Created 6 years, 6 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
« no previous file with comments | « content/browser/storage_partition_impl_map.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/storage_partition_impl_map.h" 5 #include "content/browser/storage_partition_impl_map.h"
6
7 #include "base/file_util.h"
8 #include "base/run_loop.h"
9 #include "content/public/test/test_browser_context.h"
6 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
7 11
8 namespace content { 12 namespace content {
9 13
10 class StoragePartitionConfigTest : public testing::Test {
11 };
12
13 // Test that the Less comparison function is implemented properly to uniquely 14 // Test that the Less comparison function is implemented properly to uniquely
14 // identify storage partitions used as keys in a std::map. 15 // identify storage partitions used as keys in a std::map.
15 TEST_F(StoragePartitionConfigTest, OperatorLess) { 16 TEST(StoragePartitionConfigTest, OperatorLess) {
16 StoragePartitionImplMap::StoragePartitionConfig c1( 17 StoragePartitionImplMap::StoragePartitionConfig c1(
17 std::string(), std::string(), false); 18 std::string(), std::string(), false);
18 StoragePartitionImplMap::StoragePartitionConfig c2( 19 StoragePartitionImplMap::StoragePartitionConfig c2(
19 std::string(), std::string(), false); 20 std::string(), std::string(), false);
20 StoragePartitionImplMap::StoragePartitionConfig c3( 21 StoragePartitionImplMap::StoragePartitionConfig c3(
21 std::string(), std::string(), true); 22 std::string(), std::string(), true);
22 StoragePartitionImplMap::StoragePartitionConfig c4("a", std::string(), true); 23 StoragePartitionImplMap::StoragePartitionConfig c4("a", std::string(), true);
23 StoragePartitionImplMap::StoragePartitionConfig c5("b", std::string(), true); 24 StoragePartitionImplMap::StoragePartitionConfig c5("b", std::string(), true);
24 StoragePartitionImplMap::StoragePartitionConfig c6( 25 StoragePartitionImplMap::StoragePartitionConfig c6(
25 std::string(), "abc", false); 26 std::string(), "abc", false);
(...skipping 27 matching lines...) Expand all
53 // Check for irreflexivity. 54 // Check for irreflexivity.
54 EXPECT_FALSE(less(c1, c1)); 55 EXPECT_FALSE(less(c1, c1));
55 56
56 // Check for transitivity. 57 // Check for transitivity.
57 EXPECT_TRUE(less(c1, c4)); 58 EXPECT_TRUE(less(c1, c4));
58 59
59 // Let's enforce that two identical elements obey strict weak ordering. 60 // Let's enforce that two identical elements obey strict weak ordering.
60 EXPECT_TRUE(!less(c1, c2) && !less(c2, c1)); 61 EXPECT_TRUE(!less(c1, c2) && !less(c2, c1));
61 } 62 }
62 63
64 TEST(StoragePartitionImplMapTest, GarbageCollect) {
65 base::MessageLoop message_loop;
66 TestBrowserContext browser_context;
67 StoragePartitionImplMap storage_partition_impl_map(&browser_context);
68
69 scoped_ptr<base::hash_set<base::FilePath> > active_paths(
70 new base::hash_set<base::FilePath>);
71
72 base::FilePath active_path = browser_context.GetPath().Append(
73 StoragePartitionImplMap::GetStoragePartitionPath(
74 "active", std::string()));
75 ASSERT_TRUE(base::CreateDirectory(active_path));
76 active_paths->insert(active_path);
77
78 base::FilePath inactive_path = browser_context.GetPath().Append(
79 StoragePartitionImplMap::GetStoragePartitionPath(
80 "inactive", std::string()));
81 ASSERT_TRUE(base::CreateDirectory(inactive_path));
82
83 base::RunLoop run_loop;
84 storage_partition_impl_map.GarbageCollect(
85 active_paths.Pass(), run_loop.QuitClosure());
86 run_loop.Run();
87
88 EXPECT_TRUE(base::PathExists(active_path));
89 EXPECT_FALSE(base::PathExists(inactive_path));
90 }
91
63 } // namespace content 92 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/storage_partition_impl_map.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698