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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/storage_partition_impl_unittest.cc
diff --git a/content/browser/storage_partition_impl_unittest.cc b/content/browser/storage_partition_impl_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0372f7b2f322f7c9d7ea4e0266c824aeebbb6965
--- /dev/null
+++ b/content/browser/storage_partition_impl_unittest.cc
@@ -0,0 +1,62 @@
+// Copyright (c) 2012 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 "content/browser/storage_partition_impl.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace content {
+
+namespace {
+
+class StoragePartitionDescriptorTest : public testing::Test {
+};
+
+// Test that the Less comparison function is implemented properly to uniquely
+// identify storage partitions used as keys in a std::map.
+TEST_F(StoragePartitionDescriptorTest, OperatorLess) {
+ StoragePartitionImpl::StoragePartitionDescriptor d1("", "", false);
+ StoragePartitionImpl::StoragePartitionDescriptor d2("", "", false);
+ StoragePartitionImpl::StoragePartitionDescriptor d3("", "", true);
+ StoragePartitionImpl::StoragePartitionDescriptor d4("a", "", true);
+ StoragePartitionImpl::StoragePartitionDescriptor d5("b", "", true);
+ StoragePartitionImpl::StoragePartitionDescriptor d6("", "abc", false);
+ StoragePartitionImpl::StoragePartitionDescriptor d7("", "abc", true);
+ StoragePartitionImpl::StoragePartitionDescriptor d8("a", "abc", false);
+ StoragePartitionImpl::StoragePartitionDescriptor d9("a", "abc", true);
+
+ StoragePartitionImpl::StoragePartitionDescriptorLess less;
+
+ // Let's ensure basic comparison works.
+ EXPECT_TRUE(less(d1, d3));
+ EXPECT_TRUE(less(d1, d4));
+ EXPECT_TRUE(less(d3, d4));
+ EXPECT_TRUE(less(d4, d5));
+ EXPECT_TRUE(less(d4, d8));
+ EXPECT_TRUE(less(d6, d4));
+ EXPECT_TRUE(less(d6, d7));
+ EXPECT_TRUE(less(d8, d9));
+
+ // Now, ensure antisymmetry for each pair we've tested.
+ EXPECT_FALSE(less(d3, d1));
+ EXPECT_FALSE(less(d4, d1));
+ EXPECT_FALSE(less(d4, d3));
+ EXPECT_FALSE(less(d5, d4));
+ EXPECT_FALSE(less(d8, d4));
+ EXPECT_FALSE(less(d4, d6));
+ EXPECT_FALSE(less(d7, d6));
+ EXPECT_FALSE(less(d9, d8));
+
+ // Check for irreflexivity.
+ EXPECT_FALSE(less(d1, d1));
+
+ // Check for transitivity.
+ EXPECT_TRUE(less(d1, d4));
+
+ // Let's enforce that two identical elements obey strict weak ordering.
+ EXPECT_TRUE(!less(d1, d2) && !less(d2, d1));
+}
+
+} // namespace
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698