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

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: Disabling session storage test for isolated apps. 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
« no previous file with comments | « content/browser/storage_partition_impl_map.cc ('k') | content/browser/web_contents/web_contents_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..bf74943f4c14b8f2d316702fdf1d318816c3d7dd
--- /dev/null
+++ b/content/browser/storage_partition_impl_unittest.cc
@@ -0,0 +1,58 @@
+// 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 {
+
+class StoragePartitionConfigTest : 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(StoragePartitionConfigTest, OperatorLess) {
+ StoragePartitionImpl::StoragePartitionConfig c1("", "", false);
+ StoragePartitionImpl::StoragePartitionConfig c2("", "", false);
+ StoragePartitionImpl::StoragePartitionConfig c3("", "", true);
+ StoragePartitionImpl::StoragePartitionConfig c4("a", "", true);
+ StoragePartitionImpl::StoragePartitionConfig c5("b", "", true);
+ StoragePartitionImpl::StoragePartitionConfig c6("", "abc", false);
+ StoragePartitionImpl::StoragePartitionConfig c7("", "abc", true);
+ StoragePartitionImpl::StoragePartitionConfig c8("a", "abc", false);
+ StoragePartitionImpl::StoragePartitionConfig c9("a", "abc", true);
+
+ StoragePartitionImpl::StoragePartitionConfigLess less;
+
+ // Let's ensure basic comparison works.
+ EXPECT_TRUE(less(c1, c3));
+ EXPECT_TRUE(less(c1, c4));
+ EXPECT_TRUE(less(c3, c4));
+ EXPECT_TRUE(less(c4, c5));
+ EXPECT_TRUE(less(c4, c8));
+ EXPECT_TRUE(less(c6, c4));
+ EXPECT_TRUE(less(c6, c7));
+ EXPECT_TRUE(less(c8, c9));
+
+ // Now, ensure antisymmetry for each pair we've tested.
+ EXPECT_FALSE(less(c3, c1));
+ EXPECT_FALSE(less(c4, c1));
+ EXPECT_FALSE(less(c4, c3));
+ EXPECT_FALSE(less(c5, c4));
+ EXPECT_FALSE(less(c8, c4));
+ EXPECT_FALSE(less(c4, c6));
+ EXPECT_FALSE(less(c7, c6));
+ EXPECT_FALSE(less(c9, c8));
+
+ // Check for irreflexivity.
+ EXPECT_FALSE(less(c1, c1));
+
+ // Check for transitivity.
+ EXPECT_TRUE(less(c1, c4));
+
+ // Let's enforce that two identical elements obey strict weak ordering.
+ EXPECT_TRUE(!less(c1, c2) && !less(c2, c1));
+}
+
+} // namespace content
« no previous file with comments | « content/browser/storage_partition_impl_map.cc ('k') | content/browser/web_contents/web_contents_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698