• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #include "chrome/browser/metrics/rappor/sampling.h"
6 
7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "url/gurl.h"
9 
10 namespace rappor {
11 
12 // Test that extracting the sample works correctly for different schemes.
TEST(RapporSamplingTest,GetDomainAndRegistrySampleFromGURLTest)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 }
23 
24 // Make sure recording a sample during tests, when the Rappor service is NULL,
25 // doesn't cause a crash.
TEST(RapporSamplingTest,SmokeTest)26 TEST(RapporSamplingTest, SmokeTest) {
27   SampleDomainAndRegistryFromHost(std::string(), std::string());
28   SampleDomainAndRegistryFromGURL(std::string(), GURL());
29 }
30 
31 }  // namespace rappor
32