| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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.GetByURL( |
| 83 ext2->GetResourceURL("test.html"))); | 83 ExtensionURLInfo(ext2->GetResourceURL("test.html")))); |
| 84 EXPECT_EQ(ext3, extensions.GetByURL( | 84 EXPECT_EQ(ext3, extensions.GetByURL( |
| 85 ext3->GetResourceURL("test.html"))); | 85 ExtensionURLInfo(ext3->GetResourceURL("test.html")))); |
| 86 EXPECT_EQ(ext4, extensions.GetByURL( | 86 EXPECT_EQ(ext4, extensions.GetByURL( |
| 87 ext4->GetResourceURL("test.html"))); | 87 ExtensionURLInfo(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.GetByURL( |
| 91 GURL("http://code.google.com/p/chromium/monkey"))); | 91 ExtensionURLInfo(GURL("http://code.google.com/p/chromium/monkey")))); |
| 92 EXPECT_EQ(ext3, extensions.GetByURL( | 92 EXPECT_EQ(ext3, extensions.GetByURL( |
| 93 GURL("http://dev.chromium.org/design-docs/"))); | 93 ExtensionURLInfo(GURL("http://dev.chromium.org/design-docs/")))); |
| 94 EXPECT_FALSE(extensions.GetByURL( | 94 EXPECT_FALSE(extensions.GetByURL( |
| 95 GURL("http://blog.chromium.org/"))); | 95 ExtensionURLInfo(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 |