OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/rappor/sampling.h" | 5 #include "chrome/browser/metrics/rappor/sampling.h" |
6 | 6 |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "url/gurl.h" | 8 #include "url/gurl.h" |
9 | 9 |
10 namespace rappor { | 10 namespace rappor { |
11 | 11 |
12 // Test that extracting the sample works correctly for different schemes. | 12 // Test that extracting the sample works correctly for different schemes. |
13 TEST(RapporSamplingTest, GetDomainAndRegistrySampleFromGURLTest) { | 13 TEST(RapporSamplingTest, GetDomainAndRegistrySampleFromGURLTest) { |
14 EXPECT_EQ("google.com", GetDomainAndRegistrySampleFromGURL( | 14 EXPECT_EQ("google.com", GetDomainAndRegistrySampleFromGURL( |
15 GURL("https://www.GoOgLe.com:80/blah"))); | 15 GURL("https://www.GoOgLe.com:80/blah"))); |
16 EXPECT_EQ("file://", GetDomainAndRegistrySampleFromGURL( | 16 EXPECT_EQ("file://", GetDomainAndRegistrySampleFromGURL( |
17 GURL("file://foo/bar/baz"))); | 17 GURL("file://foo/bar/baz"))); |
18 EXPECT_EQ("chrome-extension://abc1234", GetDomainAndRegistrySampleFromGURL( | 18 EXPECT_EQ("chrome-extension://abc1234", GetDomainAndRegistrySampleFromGURL( |
19 GURL("chrome-extension://abc1234/foo.html"))); | 19 GURL("chrome-extension://abc1234/foo.html"))); |
20 EXPECT_EQ("chrome-search://local-ntp", GetDomainAndRegistrySampleFromGURL( | 20 EXPECT_EQ("chrome-search://local-ntp", GetDomainAndRegistrySampleFromGURL( |
21 GURL("chrome-search://local-ntp/local-ntp.html"))); | 21 GURL("chrome-search://local-ntp/local-ntp.html"))); |
22 EXPECT_EQ("localhost", GetDomainAndRegistrySampleFromGURL( | |
23 GURL("http://localhost:8000/foo.html"))); | |
24 EXPECT_EQ("localhost", GetDomainAndRegistrySampleFromGURL( | |
25 GURL("http://127.0.0.1/foo.html"))); | |
26 EXPECT_EQ("ip_address", GetDomainAndRegistrySampleFromGURL( | |
27 GURL("http://192.168.0.1/foo.html"))); | |
28 EXPECT_EQ("ip_address", GetDomainAndRegistrySampleFromGURL( | |
29 GURL("http://[2001:db8::1]/"))); | |
Nathan Parker
2015/02/18 21:56:46
While you're here, add two more:
http://www/ -->
Steven Holte
2015/02/19 23:42:19
Done, but http://www.corp/ --> "www.corp"
| |
22 } | 30 } |
23 | 31 |
24 // Make sure recording a sample during tests, when the Rappor service is NULL, | 32 // Make sure recording a sample during tests, when the Rappor service is NULL, |
25 // doesn't cause a crash. | 33 // doesn't cause a crash. |
26 TEST(RapporSamplingTest, SmokeTest) { | 34 TEST(RapporSamplingTest, SmokeTest) { |
27 SampleDomainAndRegistryFromGURL(std::string(), GURL()); | 35 SampleDomainAndRegistryFromGURL(std::string(), GURL()); |
28 } | 36 } |
29 | 37 |
30 } // namespace rappor | 38 } // namespace rappor |
OLD | NEW |