OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/file_path.h" | 5 #include "base/file_path.h" |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/common/extensions/extension.h" | 10 #include "chrome/common/extensions/extension.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 extensions.Insert(ext2); | 72 extensions.Insert(ext2); |
73 EXPECT_EQ(1u, extensions.size()); | 73 EXPECT_EQ(1u, extensions.size()); |
74 EXPECT_EQ(ext2, extensions.GetByID(ext1->id())); | 74 EXPECT_EQ(ext2, extensions.GetByID(ext1->id())); |
75 | 75 |
76 // Add the other extensions. | 76 // Add the other extensions. |
77 extensions.Insert(ext3); | 77 extensions.Insert(ext3); |
78 extensions.Insert(ext4); | 78 extensions.Insert(ext4); |
79 EXPECT_EQ(3u, extensions.size()); | 79 EXPECT_EQ(3u, extensions.size()); |
80 | 80 |
81 // Get extension by its chrome-extension:// URL | 81 // Get extension by its chrome-extension:// URL |
82 EXPECT_EQ(ext2, extensions.GetByURL( | 82 EXPECT_EQ(ext2, extensions.GetByURLWithoutSecurityCheck( |
83 ext2->GetResourceURL("test.html"))); | 83 ext2->GetResourceURL("test.html"))); |
84 EXPECT_EQ(ext3, extensions.GetByURL( | 84 EXPECT_EQ(ext3, extensions.GetByURLWithoutSecurityCheck( |
85 ext3->GetResourceURL("test.html"))); | 85 ext3->GetResourceURL("test.html"))); |
86 EXPECT_EQ(ext4, extensions.GetByURL( | 86 EXPECT_EQ(ext4, extensions.GetByURLWithoutSecurityCheck( |
87 ext4->GetResourceURL("test.html"))); | 87 ext4->GetResourceURL("test.html"))); |
88 | 88 |
89 // Get extension by web extent. | 89 // Get extension by web extent. |
90 EXPECT_EQ(ext2, extensions.GetByURL( | 90 EXPECT_EQ(ext2, extensions.GetByURLWithoutSecurityCheck( |
91 GURL("http://code.google.com/p/chromium/monkey"))); | 91 GURL("http://code.google.com/p/chromium/monkey"))); |
92 EXPECT_EQ(ext3, extensions.GetByURL( | 92 EXPECT_EQ(ext3, extensions.GetByURLWithoutSecurityCheck( |
93 GURL("http://dev.chromium.org/design-docs/"))); | 93 GURL("http://dev.chromium.org/design-docs/"))); |
94 EXPECT_FALSE(extensions.GetByURL( | 94 EXPECT_FALSE(extensions.GetByURLWithoutSecurityCheck( |
95 GURL("http://blog.chromium.org/"))); | 95 GURL("http://blog.chromium.org/"))); |
96 | 96 |
97 // Test InSameExtent(). | 97 // Test InSameExtent(). |
98 EXPECT_TRUE(extensions.InSameExtent( | 98 EXPECT_TRUE(extensions.InSameExtent( |
99 GURL("http://code.google.com/p/chromium/monkey/"), | 99 GURL("http://code.google.com/p/chromium/monkey/"), |
100 GURL("http://code.google.com/p/chromium/"))); | 100 GURL("http://code.google.com/p/chromium/"))); |
101 EXPECT_FALSE(extensions.InSameExtent( | 101 EXPECT_FALSE(extensions.InSameExtent( |
102 GURL("http://code.google.com/p/chromium/"), | 102 GURL("http://code.google.com/p/chromium/"), |
103 GURL("https://code.google.com/p/chromium/"))); | 103 GURL("https://code.google.com/p/chromium/"))); |
104 EXPECT_FALSE(extensions.InSameExtent( | 104 EXPECT_FALSE(extensions.InSameExtent( |
105 GURL("http://code.google.com/p/chromium/"), | 105 GURL("http://code.google.com/p/chromium/"), |
106 GURL("http://dev.chromium.org/design-docs/"))); | 106 GURL("http://dev.chromium.org/design-docs/"))); |
107 | 107 |
108 // Both of these should be NULL, which mean true for InSameExtent. | 108 // Both of these should be NULL, which mean true for InSameExtent. |
109 EXPECT_TRUE(extensions.InSameExtent( | 109 EXPECT_TRUE(extensions.InSameExtent( |
110 GURL("http://www.google.com/"), | 110 GURL("http://www.google.com/"), |
111 GURL("http://blog.chromium.org/"))); | 111 GURL("http://blog.chromium.org/"))); |
112 | 112 |
113 // Remove one of the extensions. | 113 // Remove one of the extensions. |
114 extensions.Remove(ext2->id()); | 114 extensions.Remove(ext2->id()); |
115 EXPECT_EQ(2u, extensions.size()); | 115 EXPECT_EQ(2u, extensions.size()); |
116 EXPECT_FALSE(extensions.GetByID(ext2->id())); | 116 EXPECT_FALSE(extensions.GetByID(ext2->id())); |
117 } | 117 } |
OLD | NEW |