Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / metrics / signin_status_metrics_provider_unittest.cc
blobdc4ceb1642abf73fbf51b68bf7ef85bd9c87a404
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.
5 #include "chrome/browser/metrics/signin_status_metrics_provider.h"
7 #include <string>
9 #include "base/files/file_path.h"
10 #include "testing/gtest/include/gtest/gtest.h"
12 TEST(SigninStatusMetricsProvider, UpdateInitialSigninStatus) {
13 SigninStatusMetricsProvider metrics_provider(true);
14 metrics_provider.UpdateInitialSigninStatus(2, 2);
15 EXPECT_EQ(SigninStatusMetricsProviderBase::ALL_PROFILES_SIGNED_IN,
16 metrics_provider.GetSigninStatusForTesting());
17 metrics_provider.UpdateInitialSigninStatus(2, 0);
18 EXPECT_EQ(SigninStatusMetricsProviderBase::ALL_PROFILES_NOT_SIGNED_IN,
19 metrics_provider.GetSigninStatusForTesting());
20 metrics_provider.UpdateInitialSigninStatus(2, 1);
21 EXPECT_EQ(SigninStatusMetricsProviderBase::MIXED_SIGNIN_STATUS,
22 metrics_provider.GetSigninStatusForTesting());
25 #if !defined(OS_ANDROID) && !defined(OS_IOS)
26 TEST(SigninStatusMetricsProvider, UpdateStatusWhenBrowserAdded) {
27 SigninStatusMetricsProvider metrics_provider(true);
29 // Initial status is all signed in and then a signed-in browser is opened.
30 metrics_provider.UpdateInitialSigninStatus(2, 2);
31 metrics_provider.UpdateStatusWhenBrowserAdded(true);
32 EXPECT_EQ(SigninStatusMetricsProviderBase::ALL_PROFILES_SIGNED_IN,
33 metrics_provider.GetSigninStatusForTesting());
35 // Initial status is all signed in and then a signed-out browser is opened.
36 metrics_provider.UpdateInitialSigninStatus(2, 2);
37 metrics_provider.UpdateStatusWhenBrowserAdded(false);
38 EXPECT_EQ(SigninStatusMetricsProviderBase::MIXED_SIGNIN_STATUS,
39 metrics_provider.GetSigninStatusForTesting());
41 // Initial status is all signed out and then a signed-in browser is opened.
42 metrics_provider.UpdateInitialSigninStatus(2, 0);
43 metrics_provider.UpdateStatusWhenBrowserAdded(true);
44 EXPECT_EQ(SigninStatusMetricsProviderBase::MIXED_SIGNIN_STATUS,
45 metrics_provider.GetSigninStatusForTesting());
47 // Initial status is all signed out and then a signed-out browser is opened.
48 metrics_provider.UpdateInitialSigninStatus(2, 0);
49 metrics_provider.UpdateStatusWhenBrowserAdded(false);
50 EXPECT_EQ(SigninStatusMetricsProviderBase::ALL_PROFILES_NOT_SIGNED_IN,
51 metrics_provider.GetSigninStatusForTesting());
53 // Initial status is mixed and then a signed-in browser is opened.
54 metrics_provider.UpdateInitialSigninStatus(2, 1);
55 metrics_provider.UpdateStatusWhenBrowserAdded(true);
56 EXPECT_EQ(SigninStatusMetricsProviderBase::MIXED_SIGNIN_STATUS,
57 metrics_provider.GetSigninStatusForTesting());
59 // Initial status is mixed and then a signed-out browser is opened.
60 metrics_provider.UpdateInitialSigninStatus(2, 1);
61 metrics_provider.UpdateStatusWhenBrowserAdded(false);
62 EXPECT_EQ(SigninStatusMetricsProviderBase::MIXED_SIGNIN_STATUS,
63 metrics_provider.GetSigninStatusForTesting());
65 #endif
67 TEST(SigninStatusMetricsProvider, GoogleSigninSucceeded) {
68 SigninStatusMetricsProvider metrics_provider(true);
70 // Initial status is all signed out and then one of the profiles is signed in.
71 metrics_provider.UpdateInitialSigninStatus(2, 0);
72 metrics_provider.GoogleSigninSucceeded(std::string(), std::string(),
73 std::string());
74 EXPECT_EQ(SigninStatusMetricsProviderBase::MIXED_SIGNIN_STATUS,
75 metrics_provider.GetSigninStatusForTesting());
77 // Initial status is mixed and then one of the profiles is signed in.
78 metrics_provider.UpdateInitialSigninStatus(2, 1);
79 metrics_provider.GoogleSigninSucceeded(std::string(), std::string(),
80 std::string());
81 EXPECT_EQ(SigninStatusMetricsProviderBase::MIXED_SIGNIN_STATUS,
82 metrics_provider.GetSigninStatusForTesting());
85 TEST(SigninStatusMetricsProvider, GoogleSignedOut) {
86 SigninStatusMetricsProvider metrics_provider(true);
88 // Initial status is all signed in and then one of the profiles is signed out.
89 metrics_provider.UpdateInitialSigninStatus(2, 2);
90 metrics_provider.GoogleSignedOut(std::string(), std::string());
91 EXPECT_EQ(SigninStatusMetricsProviderBase::MIXED_SIGNIN_STATUS,
92 metrics_provider.GetSigninStatusForTesting());
94 // Initial status is mixed and then one of the profiles is signed out.
95 metrics_provider.UpdateInitialSigninStatus(2, 1);
96 metrics_provider.GoogleSignedOut(std::string(), std::string());
97 EXPECT_EQ(SigninStatusMetricsProviderBase::MIXED_SIGNIN_STATUS,
98 metrics_provider.GetSigninStatusForTesting());