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

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

Issue 11234032: Webview tag creation should be using storage partitions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removing the custom format of partition id. Created 8 years, 1 month 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/browser/storage_partition_impl.h"
6 #include "testing/gtest/include/gtest/gtest.h"
7
8 namespace content {
9
10 namespace {
11
12 class StoragePartitionDescriptorTest : public testing::Test {
13 };
14
15 // Test that the Less comparison function is implemented properly to uniquely
16 // identify storage partitions used as keys in a std::map.
17 TEST_F(StoragePartitionDescriptorTest, OperatorLess) {
18 StoragePartitionImpl::StoragePartitionDescriptor d1("", "", false);
19 StoragePartitionImpl::StoragePartitionDescriptor d2("", "", false);
20 StoragePartitionImpl::StoragePartitionDescriptor d3("", "", true);
21 StoragePartitionImpl::StoragePartitionDescriptor d4("a", "", true);
22 StoragePartitionImpl::StoragePartitionDescriptor d5("b", "", true);
23 StoragePartitionImpl::StoragePartitionDescriptor d6("", "abc", false);
24 StoragePartitionImpl::StoragePartitionDescriptor d7("", "abc", true);
25 StoragePartitionImpl::StoragePartitionDescriptor d8("a", "abc", false);
26 StoragePartitionImpl::StoragePartitionDescriptor d9("a", "abc", true);
27
28 StoragePartitionImpl::StoragePartitionDescriptorLess less;
29
30 // Let's ensure basic comparison works.
31 EXPECT_TRUE(less(d1, d3));
32 EXPECT_TRUE(less(d1, d4));
33 EXPECT_TRUE(less(d3, d4));
34 EXPECT_TRUE(less(d4, d5));
35 EXPECT_TRUE(less(d4, d8));
36 EXPECT_TRUE(less(d6, d4));
37 EXPECT_TRUE(less(d6, d7));
38 EXPECT_TRUE(less(d8, d9));
39
40 // Now, ensure antisymmetry for each pair we've tested.
41 EXPECT_FALSE(less(d3, d1));
42 EXPECT_FALSE(less(d4, d1));
43 EXPECT_FALSE(less(d4, d3));
44 EXPECT_FALSE(less(d5, d4));
45 EXPECT_FALSE(less(d8, d4));
46 EXPECT_FALSE(less(d4, d6));
47 EXPECT_FALSE(less(d7, d6));
48 EXPECT_FALSE(less(d9, d8));
49
50 // Check for irreflexivity.
51 EXPECT_FALSE(less(d1, d1));
52
53 // Check for transitivity.
54 EXPECT_TRUE(less(d1, d4));
55
56 // Let's enforce that two identical elements obey strict weak ordering.
57 EXPECT_TRUE(!less(d1, d2) && !less(d2, d1));
58 }
59
60 } // namespace
61
62 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698