cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / components / rappor / rappor_utils_unittest.cc
blob4b1fba5c83e5eccd011e62f7a3101b47ee3a8803
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "components/rappor/rappor_utils.h"
7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "url/gurl.h"
10 namespace rappor {
12 // Test that extracting the sample works correctly for different schemes.
13 TEST(RapporSamplingTest, GetDomainAndRegistrySampleFromGURLTest) {
14 EXPECT_EQ("google.com", GetDomainAndRegistrySampleFromGURL(
15 GURL("https://www.GoOgLe.com:80/blah")));
16 EXPECT_EQ("file://", GetDomainAndRegistrySampleFromGURL(
17 GURL("file://foo/bar/baz")));
18 EXPECT_EQ("chrome-extension://abc1234", GetDomainAndRegistrySampleFromGURL(
19 GURL("chrome-extension://abc1234/foo.html")));
20 EXPECT_EQ("chrome-search://local-ntp", GetDomainAndRegistrySampleFromGURL(
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]/")));
30 EXPECT_EQ("", GetDomainAndRegistrySampleFromGURL(
31 GURL("http://www/")));
32 EXPECT_EQ("www.corp", GetDomainAndRegistrySampleFromGURL(
33 GURL("http://www.corp/")));
36 // Make sure recording a sample during tests, when the Rappor service is NULL,
37 // doesn't cause a crash.
38 TEST(RapporSamplingTest, SmokeTest) {
39 SampleDomainAndRegistryFromGURL(NULL, std::string(), GURL());
42 } // namespace rappor