Componentize component_updater: Copy over test data with executable bit.
[chromium-blink-merge.git] / chrome / browser / metrics / signin_status_metrics_provider_unittest.cc
blob463eb1dcea5ea3780a4f422382a9d42bbb636042
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(SigninStatusMetricsProvider::ALL_PROFILES_SIGNED_IN,
16 metrics_provider.GetSigninStatusForTesting());
17 metrics_provider.UpdateInitialSigninStatus(2, 0);
18 EXPECT_EQ(SigninStatusMetricsProvider::ALL_PROFILES_NOT_SIGNED_IN,
19 metrics_provider.GetSigninStatusForTesting());
20 metrics_provider.UpdateInitialSigninStatus(2, 1);
21 EXPECT_EQ(SigninStatusMetricsProvider::MIXED_SIGNIN_STATUS,
22 metrics_provider.GetSigninStatusForTesting());
23 metrics_provider.UpdateInitialSigninStatus(0, 0);
24 EXPECT_EQ(SigninStatusMetricsProvider::UNKNOWN_SIGNIN_STATUS,
25 metrics_provider.GetSigninStatusForTesting());
28 #if !defined(OS_ANDROID)
29 TEST(SigninStatusMetricsProvider, UpdateStatusWhenBrowserAdded) {
30 SigninStatusMetricsProvider metrics_provider(true);
32 // Initial status is all signed in and then a signed-in browser is opened.
33 metrics_provider.UpdateInitialSigninStatus(2, 2);
34 metrics_provider.UpdateStatusWhenBrowserAdded(true);
35 EXPECT_EQ(SigninStatusMetricsProvider::ALL_PROFILES_SIGNED_IN,
36 metrics_provider.GetSigninStatusForTesting());
38 // Initial status is all signed in and then a signed-out browser is opened.
39 metrics_provider.UpdateInitialSigninStatus(2, 2);
40 metrics_provider.UpdateStatusWhenBrowserAdded(false);
41 EXPECT_EQ(SigninStatusMetricsProvider::MIXED_SIGNIN_STATUS,
42 metrics_provider.GetSigninStatusForTesting());
44 // Initial status is all signed out and then a signed-in browser is opened.
45 metrics_provider.UpdateInitialSigninStatus(2, 0);
46 metrics_provider.UpdateStatusWhenBrowserAdded(true);
47 EXPECT_EQ(SigninStatusMetricsProvider::MIXED_SIGNIN_STATUS,
48 metrics_provider.GetSigninStatusForTesting());
50 // Initial status is all signed out and then a signed-out browser is opened.
51 metrics_provider.UpdateInitialSigninStatus(2, 0);
52 metrics_provider.UpdateStatusWhenBrowserAdded(false);
53 EXPECT_EQ(SigninStatusMetricsProvider::ALL_PROFILES_NOT_SIGNED_IN,
54 metrics_provider.GetSigninStatusForTesting());
56 // Initial status is mixed and then a signed-in browser is opened.
57 metrics_provider.UpdateInitialSigninStatus(2, 1);
58 metrics_provider.UpdateStatusWhenBrowserAdded(true);
59 EXPECT_EQ(SigninStatusMetricsProvider::MIXED_SIGNIN_STATUS,
60 metrics_provider.GetSigninStatusForTesting());
62 // Initial status is mixed and then a signed-out browser is opened.
63 metrics_provider.UpdateInitialSigninStatus(2, 1);
64 metrics_provider.UpdateStatusWhenBrowserAdded(false);
65 EXPECT_EQ(SigninStatusMetricsProvider::MIXED_SIGNIN_STATUS,
66 metrics_provider.GetSigninStatusForTesting());
68 #endif
70 TEST(SigninStatusMetricsProvider, GoogleSigninSucceeded) {
71 SigninStatusMetricsProvider metrics_provider(true);
73 // Initial status is all signed out and then one of the profiles is signed in.
74 metrics_provider.UpdateInitialSigninStatus(2, 0);
75 metrics_provider.GoogleSigninSucceeded(std::string(), std::string());
76 EXPECT_EQ(SigninStatusMetricsProvider::MIXED_SIGNIN_STATUS,
77 metrics_provider.GetSigninStatusForTesting());
79 // Initial status is mixed and then one of the profiles is signed in.
80 metrics_provider.UpdateInitialSigninStatus(2, 1);
81 metrics_provider.GoogleSigninSucceeded(std::string(), std::string());
82 EXPECT_EQ(SigninStatusMetricsProvider::MIXED_SIGNIN_STATUS,
83 metrics_provider.GetSigninStatusForTesting());
86 TEST(SigninStatusMetricsProvider, GoogleSignedOut) {
87 SigninStatusMetricsProvider metrics_provider(true);
89 // Initial status is all signed in and then one of the profiles is signed out.
90 metrics_provider.UpdateInitialSigninStatus(2, 2);
91 metrics_provider.GoogleSignedOut(std::string());
92 EXPECT_EQ(SigninStatusMetricsProvider::MIXED_SIGNIN_STATUS,
93 metrics_provider.GetSigninStatusForTesting());
95 // Initial status is mixed and then one of the profiles is signed out.
96 metrics_provider.UpdateInitialSigninStatus(2, 1);
97 metrics_provider.GoogleSignedOut(std::string());
98 EXPECT_EQ(SigninStatusMetricsProvider::MIXED_SIGNIN_STATUS,
99 metrics_provider.GetSigninStatusForTesting());