Index: components/variations/variations_http_header_provider_unittest.cc |
diff --git a/chrome/browser/metrics/variations/variations_http_header_provider_unittest.cc b/components/variations/variations_http_header_provider_unittest.cc |
similarity index 54% |
rename from chrome/browser/metrics/variations/variations_http_header_provider_unittest.cc |
rename to components/variations/variations_http_header_provider_unittest.cc |
index 2e644c4878cf27e540ea8f753b2b911ac13b463a..419d2806a563c65f3b9e805244e670442dbaf36d 100644 |
--- a/chrome/browser/metrics/variations/variations_http_header_provider_unittest.cc |
+++ b/components/variations/variations_http_header_provider_unittest.cc |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "chrome/browser/metrics/variations/variations_http_header_provider.h" |
+#include "components/variations/variations_http_header_provider.h" |
#include <string> |
@@ -10,14 +10,20 @@ |
#include "base/message_loop/message_loop.h" |
#include "base/metrics/field_trial.h" |
#include "base/run_loop.h" |
-#include "chrome/browser/metrics/variations/proto/chrome_experiments.pb.h" |
#include "components/variations/entropy_provider.h" |
+#include "components/variations/proto/chrome_experiments.pb.h" |
#include "components/variations/variations_associated_data.h" |
#include "net/http/http_request_headers.h" |
#include "testing/gtest/include/gtest/gtest.h" |
#include "url/gurl.h" |
-namespace chrome_variations { |
+// TODO(mathp): Remove once everything is under namespace 'variations'. |
+using chrome_variations::GOOGLE_WEB_PROPERTIES; |
+using chrome_variations::GOOGLE_WEB_PROPERTIES_TRIGGER; |
+using chrome_variations::IDCollectionKey; |
+using chrome_variations::VariationID; |
+ |
+namespace variations { |
namespace { |
@@ -26,11 +32,9 @@ bool ExtractVariationIds(const std::string& variations, |
std::set<VariationID>* variation_ids, |
std::set<VariationID>* trigger_ids) { |
std::string serialized_proto; |
- if (!base::Base64Decode(variations, &serialized_proto)) |
- return false; |
+ if (!base::Base64Decode(variations, &serialized_proto)) return false; |
metrics::ChromeVariations proto; |
- if (!proto.ParseFromString(serialized_proto)) |
- return false; |
+ if (!proto.ParseFromString(serialized_proto)) return false; |
for (int i = 0; i < proto.variation_id_size(); ++i) |
variation_ids->insert(proto.variation_id(i)); |
for (int i = 0; i < proto.trigger_variation_id_size(); ++i) |
@@ -39,10 +43,8 @@ bool ExtractVariationIds(const std::string& variations, |
} |
scoped_refptr<base::FieldTrial> CreateTrialAndAssociateId( |
- const std::string& trial_name, |
- const std::string& default_group_name, |
- IDCollectionKey key, |
- VariationID id) { |
+ const std::string& trial_name, const std::string& default_group_name, |
+ IDCollectionKey key, VariationID id) { |
scoped_refptr<base::FieldTrial> trial( |
base::FieldTrialList::CreateFieldTrial(trial_name, default_group_name)); |
@@ -61,7 +63,7 @@ class VariationsHttpHeaderProviderTest : public ::testing::Test { |
virtual ~VariationsHttpHeaderProviderTest() {} |
virtual void TearDown() OVERRIDE { |
- testing::ClearAllVariationIDs(); |
+ chrome_variations::testing::ClearAllVariationIDs(); |
} |
}; |
@@ -70,96 +72,97 @@ TEST_F(VariationsHttpHeaderProviderTest, ShouldAppendHeaders) { |
const char* url; |
bool should_append_headers; |
} cases[] = { |
- { "http://google.com", true }, |
- { "http://www.google.com", true }, |
- { "http://m.google.com", true }, |
- { "http://google.ca", true }, |
- { "https://google.ca", true }, |
- { "http://google.co.uk", true }, |
- { "http://google.co.uk:8080/", true }, |
- { "http://www.google.co.uk:8080/", true }, |
- { "http://google", false }, |
- |
- { "http://youtube.com", true }, |
- { "http://www.youtube.com", true }, |
- { "http://www.youtube.ca", true }, |
- { "http://www.youtube.co.uk:8080/", true }, |
- { "https://www.youtube.com", true }, |
- { "http://youtube", false }, |
- |
- { "http://www.yahoo.com", false }, |
- |
- { "http://ad.doubleclick.net", true }, |
- { "https://a.b.c.doubleclick.net", true }, |
- { "https://a.b.c.doubleclick.net:8081", true }, |
- { "http://www.doubleclick.com", true }, |
- { "http://www.doubleclick.org", false }, |
- { "http://www.doubleclick.net.com", false }, |
- { "https://www.doubleclick.net.com", false }, |
- |
- { "http://ad.googlesyndication.com", true }, |
- { "https://a.b.c.googlesyndication.com", true }, |
- { "https://a.b.c.googlesyndication.com:8080", true }, |
- { "http://www.doubleclick.edu", false }, |
- { "http://www.googlesyndication.com.edu", false }, |
- { "https://www.googlesyndication.com.com", false }, |
- |
- { "http://www.googleadservices.com", true }, |
- { "http://www.googleadservices.com:8080", true }, |
- { "https://www.googleadservices.com", true }, |
- { "https://www.internal.googleadservices.com", true }, |
- { "https://www2.googleadservices.com", true }, |
- { "https://www.googleadservices.org", false }, |
- { "https://www.googleadservices.com.co.uk", false }, |
- |
- { "http://WWW.ANDROID.COM", true }, |
- { "http://www.android.com", true }, |
- { "http://www.doubleclick.com", true }, |
- { "http://www.doubleclick.net", true }, |
- { "http://www.ggpht.com", true }, |
- { "http://www.googleadservices.com", true }, |
- { "http://www.googleapis.com", true }, |
- { "http://www.googlesyndication.com", true }, |
- { "http://www.googleusercontent.com", true }, |
- { "http://www.googlevideo.com", true }, |
- { "http://ssl.gstatic.com", true }, |
- { "http://www.gstatic.com", true }, |
- { "http://www.ytimg.com", true }, |
- { "http://wwwytimg.com", false }, |
- { "http://ytimg.com", false }, |
- |
- { "http://www.android.org", false }, |
- { "http://www.doubleclick.org", false }, |
- { "http://www.doubleclick.net", true }, |
- { "http://www.ggpht.org", false }, |
- { "http://www.googleadservices.org", false }, |
- { "http://www.googleapis.org", false }, |
- { "http://www.googlesyndication.org", false }, |
- { "http://www.googleusercontent.org", false }, |
- { "http://www.googlevideo.org", false }, |
- { "http://ssl.gstatic.org", false }, |
- { "http://www.gstatic.org", false }, |
- { "http://www.ytimg.org", false }, |
- |
- { "http://a.b.android.com", true }, |
- { "http://a.b.doubleclick.com", true }, |
- { "http://a.b.doubleclick.net", true }, |
- { "http://a.b.ggpht.com", true }, |
- { "http://a.b.googleadservices.com", true }, |
- { "http://a.b.googleapis.com", true }, |
- { "http://a.b.googlesyndication.com", true }, |
- { "http://a.b.googleusercontent.com", true }, |
- { "http://a.b.googlevideo.com", true }, |
- { "http://ssl.gstatic.com", true }, |
- { "http://a.b.gstatic.com", true }, |
- { "http://a.b.ytimg.com", true }, |
- |
- }; |
+ {"http://google.com", true}, |
+ {"http://www.google.com", true}, |
+ {"http://m.google.com", true}, |
+ {"http://google.ca", true}, |
+ {"https://google.ca", true}, |
+ {"http://google.co.uk", true}, |
+ {"http://google.co.uk:8080/", true}, |
+ {"http://www.google.co.uk:8080/", true}, |
+ {"http://google", false}, |
+ |
+ {"http://youtube.com", true}, |
+ {"http://www.youtube.com", true}, |
+ {"http://www.youtube.ca", true}, |
+ {"http://www.youtube.co.uk:8080/", true}, |
+ {"https://www.youtube.com", true}, |
+ {"http://youtube", false}, |
+ |
+ {"http://www.yahoo.com", false}, |
+ |
+ {"http://ad.doubleclick.net", true}, |
+ {"https://a.b.c.doubleclick.net", true}, |
+ {"https://a.b.c.doubleclick.net:8081", true}, |
+ {"http://www.doubleclick.com", true}, |
+ {"http://www.doubleclick.org", false}, |
+ {"http://www.doubleclick.net.com", false}, |
+ {"https://www.doubleclick.net.com", false}, |
+ |
+ {"http://ad.googlesyndication.com", true}, |
+ {"https://a.b.c.googlesyndication.com", true}, |
+ {"https://a.b.c.googlesyndication.com:8080", true}, |
+ {"http://www.doubleclick.edu", false}, |
+ {"http://www.googlesyndication.com.edu", false}, |
+ {"https://www.googlesyndication.com.com", false}, |
+ |
+ {"http://www.googleadservices.com", true}, |
+ {"http://www.googleadservices.com:8080", true}, |
+ {"https://www.googleadservices.com", true}, |
+ {"https://www.internal.googleadservices.com", true}, |
+ {"https://www2.googleadservices.com", true}, |
+ {"https://www.googleadservices.org", false}, |
+ {"https://www.googleadservices.com.co.uk", false}, |
+ |
+ {"http://WWW.ANDROID.COM", true}, |
+ {"http://www.android.com", true}, |
+ {"http://www.doubleclick.com", true}, |
+ {"http://www.doubleclick.net", true}, |
+ {"http://www.ggpht.com", true}, |
+ {"http://www.googleadservices.com", true}, |
+ {"http://www.googleapis.com", true}, |
+ {"http://www.googlesyndication.com", true}, |
+ {"http://www.googleusercontent.com", true}, |
+ {"http://www.googlevideo.com", true}, |
+ {"http://ssl.gstatic.com", true}, |
+ {"http://www.gstatic.com", true}, |
+ {"http://www.ytimg.com", true}, |
+ {"http://wwwytimg.com", false}, |
+ {"http://ytimg.com", false}, |
+ |
+ {"http://www.android.org", false}, |
+ {"http://www.doubleclick.org", false}, |
+ {"http://www.doubleclick.net", true}, |
+ {"http://www.ggpht.org", false}, |
+ {"http://www.googleadservices.org", false}, |
+ {"http://www.googleapis.org", false}, |
+ {"http://www.googlesyndication.org", false}, |
+ {"http://www.googleusercontent.org", false}, |
+ {"http://www.googlevideo.org", false}, |
+ {"http://ssl.gstatic.org", false}, |
+ {"http://www.gstatic.org", false}, |
+ {"http://www.ytimg.org", false}, |
+ |
+ {"http://a.b.android.com", true}, |
+ {"http://a.b.doubleclick.com", true}, |
+ {"http://a.b.doubleclick.net", true}, |
+ {"http://a.b.ggpht.com", true}, |
+ {"http://a.b.googleadservices.com", true}, |
+ {"http://a.b.googleapis.com", true}, |
+ {"http://a.b.googlesyndication.com", true}, |
+ {"http://a.b.googleusercontent.com", true}, |
+ {"http://a.b.googlevideo.com", true}, |
+ {"http://ssl.gstatic.com", true}, |
+ {"http://a.b.gstatic.com", true}, |
+ {"http://a.b.ytimg.com", true}, |
+ |
+ }; |
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { |
const GURL url(cases[i].url); |
EXPECT_EQ(cases[i].should_append_headers, |
- VariationsHttpHeaderProvider::ShouldAppendHeaders(url)) << url; |
+ VariationsHttpHeaderProvider::ShouldAppendHeaders(url)) |
+ << url; |
} |
} |
@@ -239,4 +242,4 @@ TEST_F(VariationsHttpHeaderProviderTest, OnFieldTrialGroupFinalized) { |
EXPECT_TRUE(trigger_ids.find(456) != trigger_ids.end()); |
} |
-} // namespace chrome_variations |
+} // namespace variations |