OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/metrics/variations/variations_http_header_provider.h" | 5 #include "chrome/browser/metrics/variations/variations_http_header_provider.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 bool should_append_headers; | 39 bool should_append_headers; |
40 } cases[] = { | 40 } cases[] = { |
41 { "http://google.com", true }, | 41 { "http://google.com", true }, |
42 { "http://www.google.com", true }, | 42 { "http://www.google.com", true }, |
43 { "http://m.google.com", true }, | 43 { "http://m.google.com", true }, |
44 { "http://google.ca", true }, | 44 { "http://google.ca", true }, |
45 { "https://google.ca", true }, | 45 { "https://google.ca", true }, |
46 { "http://google.co.uk", true }, | 46 { "http://google.co.uk", true }, |
47 { "http://google.co.uk:8080/", true }, | 47 { "http://google.co.uk:8080/", true }, |
48 { "http://www.google.co.uk:8080/", true }, | 48 { "http://www.google.co.uk:8080/", true }, |
| 49 { "http://google", false }, |
| 50 |
49 { "http://youtube.com", true }, | 51 { "http://youtube.com", true }, |
50 { "http://www.youtube.com", true }, | 52 { "http://www.youtube.com", true }, |
51 { "http://www.youtube.ca", true }, | 53 { "http://www.youtube.ca", true }, |
52 { "http://www.youtube.co.uk:8080/", true }, | 54 { "http://www.youtube.co.uk:8080/", true }, |
53 { "https://www.youtube.com", true }, | 55 { "https://www.youtube.com", true }, |
| 56 { "http://youtube", false }, |
| 57 |
54 { "http://www.yahoo.com", false }, | 58 { "http://www.yahoo.com", false }, |
55 { "http://youtube", false }, | 59 |
56 { "http://google", false }, | 60 { "http://ad.doubleclick.net", true }, |
| 61 { "https://a.b.c.doubleclick.net", true }, |
| 62 { "https://a.b.c.doubleclick.net:8081", true }, |
| 63 { "http://www.doubleclick.com", false }, |
| 64 { "http://www.doubleclick.net.com", false }, |
| 65 { "https://www.doubleclick.net.com", false }, |
| 66 |
| 67 { "http://ad.googlesyndication.com", true }, |
| 68 { "https://a.b.c.googlesyndication.com", true }, |
| 69 { "https://a.b.c.googlesyndication.com:8080", true }, |
| 70 { "http://www.doubleclick.edu", false }, |
| 71 { "http://www.googlesyndication.com.edu", false }, |
| 72 { "https://www.googlesyndication.com.com", false }, |
| 73 |
| 74 { "http://www.googleadservices.com", true }, |
| 75 { "http://www.googleadservices.com:8080", true }, |
| 76 { "https://www.googleadservices.com", true }, |
| 77 { "https://www.internal.googleadservices.com", false }, |
| 78 { "https://www2.googleadservices.com", false }, |
| 79 { "https://www.googleadservices.org", false }, |
| 80 { "https://www.googleadservices.com.co.uk", false }, |
57 }; | 81 }; |
58 | 82 |
59 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { | 83 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { |
60 const GURL url(cases[i].url); | 84 const GURL url(cases[i].url); |
61 EXPECT_EQ(cases[i].should_append_headers, | 85 EXPECT_EQ(cases[i].should_append_headers, |
62 VariationsHttpHeaderProvider::ShouldAppendHeaders(url)) << url; | 86 VariationsHttpHeaderProvider::ShouldAppendHeaders(url)) << url; |
63 } | 87 } |
64 } | 88 } |
65 | 89 |
66 TEST(VariationsHttpHeaderProviderTest, SetDefaultVariationIds_Valid) { | 90 TEST(VariationsHttpHeaderProviderTest, SetDefaultVariationIds_Valid) { |
(...skipping 22 matching lines...) Expand all Loading... |
89 net::HttpRequestHeaders headers; | 113 net::HttpRequestHeaders headers; |
90 | 114 |
91 // Invalid experiment ids. | 115 // Invalid experiment ids. |
92 EXPECT_FALSE(provider.SetDefaultVariationIds("abcd12,456")); | 116 EXPECT_FALSE(provider.SetDefaultVariationIds("abcd12,456")); |
93 provider.InitVariationIDsCacheIfNeeded(); | 117 provider.InitVariationIDsCacheIfNeeded(); |
94 provider.AppendHeaders(url, false, false, &headers); | 118 provider.AppendHeaders(url, false, false, &headers); |
95 EXPECT_FALSE(headers.HasHeader("X-Client-Data")); | 119 EXPECT_FALSE(headers.HasHeader("X-Client-Data")); |
96 } | 120 } |
97 | 121 |
98 } // namespace chrome_variations | 122 } // namespace chrome_variations |
OLD | NEW |