summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/user_script_master_unittest.cc
diff options
context:
space:
mode:
authorjstritar@chromium.org <jstritar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-12 19:38:29 +0000
committerjstritar@chromium.org <jstritar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-12 19:38:29 +0000
commit33ccd923b68f5f202230f5a400021f3efd304439 (patch)
treec8c57a6de3b69286738be878683594f40a0c936d /chrome/browser/extensions/user_script_master_unittest.cc
parent2261b8bbffdf8abd12837326b0d0676f8eddb744 (diff)
downloadchromium_src-33ccd923b68f5f202230f5a400021f3efd304439.zip
chromium_src-33ccd923b68f5f202230f5a400021f3efd304439.tar.gz
chromium_src-33ccd923b68f5f202230f5a400021f3efd304439.tar.bz2
Update URLPatternSet to contain a std::set instead of std::vector.
This updates URLPatternSet to contain a std::set instead of a std::vector, making it easier to implement the set operations in ExtensionPermissionSet. BUG=84507 TEST=unit_tests Review URL: http://codereview.chromium.org/7347011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@92219 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/user_script_master_unittest.cc')
-rw-r--r--chrome/browser/extensions/user_script_master_unittest.cc23
1 files changed, 16 insertions, 7 deletions
diff --git a/chrome/browser/extensions/user_script_master_unittest.cc b/chrome/browser/extensions/user_script_master_unittest.cc
index c5d6af1..0ae3a4c 100644
--- a/chrome/browser/extensions/user_script_master_unittest.cc
+++ b/chrome/browser/extensions/user_script_master_unittest.cc
@@ -19,6 +19,15 @@
#include "content/common/notification_service.h"
#include "testing/gtest/include/gtest/gtest.h"
+namespace {
+
+static void AddPattern(URLPatternSet* extent, const std::string& pattern) {
+ int schemes = URLPattern::SCHEME_ALL;
+ extent->AddPattern(URLPattern(schemes, pattern));
+}
+
+}
+
// Test bringing up a master on a specific directory, putting a script
// in there, etc.
@@ -142,15 +151,15 @@ TEST_F(UserScriptMasterTest, Parse4) {
"// @match \t http://mail.yahoo.com/*\n"
"// ==/UserScript==\n");
+ URLPatternSet expected_patterns;
+ AddPattern(&expected_patterns, "http://*.mail.google.com/*");
+ AddPattern(&expected_patterns, "http://mail.yahoo.com/*");
+
UserScript script;
EXPECT_TRUE(UserScriptMaster::ScriptReloader::ParseMetadataHeader(
text, &script));
EXPECT_EQ(0U, script.globs().size());
- ASSERT_EQ(2U, script.url_patterns().size());
- EXPECT_EQ("http://*.mail.google.com/*",
- script.url_patterns()[0].GetAsString());
- EXPECT_EQ("http://mail.yahoo.com/*",
- script.url_patterns()[1].GetAsString());
+ EXPECT_EQ(expected_patterns, script.url_patterns());
}
TEST_F(UserScriptMasterTest, Parse5) {
@@ -192,9 +201,9 @@ TEST_F(UserScriptMasterTest, Parse7) {
text, &script));
ASSERT_EQ("hello", script.name());
ASSERT_EQ("wiggity woo", script.description());
- ASSERT_EQ(1U, script.url_patterns().size());
+ ASSERT_EQ(1U, script.url_patterns().patterns().size());
EXPECT_EQ("http://mail.yahoo.com/*",
- script.url_patterns()[0].GetAsString());
+ script.url_patterns().begin()->GetAsString());
}
TEST_F(UserScriptMasterTest, SkipBOMAtTheBeginning) {