Skip to content

Commit

Permalink
Adding unittest for disabled metrics reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
jumde committed Mar 22, 2019
1 parent 1ef91e4 commit 6e9931e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
27 changes: 27 additions & 0 deletions chromium_src/components/metrics/enabled_state_provider_unittest.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* Copyright (c) 2019 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "chrome/browser/metrics/chrome_metrics_services_manager_client.h"

#include "chrome/browser/metrics/chrome_metrics_service_accessor.h"
#include "components/metrics/enabled_state_provider.h"
#include "components/metrics/metrics_pref_names.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/testing_pref_service.h"
#include "testing/gtest/include/gtest/gtest.h"

TEST(ChromeMetricsServicesManagerClient, MetricsReportingDisabled) {
TestingPrefServiceSimple local_state;
metrics::RegisterMetricsReportingStatePrefs(local_state.registry());
local_state.registry()->RegisterBooleanPref(
metrics::prefs::kMetricsReportingEnabled, true);

ChromeMetricsServicesManagerClient client(&local_state);
const metrics::EnabledStateProvider& provider =
client.GetEnabledStateProviderForTesting();

// Reporting should never be enabled
EXPECT_FALSE(provider.IsReportingEnabled());
}
1 change: 1 addition & 0 deletions test/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ test("brave_unit_tests") {
"//brave/chromium_src/chrome/browser/history/history_utils_unittest.cc",
"//brave/chromium_src/chrome/browser/signin/account_consistency_disabled_unittest.cc",
"//brave/chromium_src/chrome/browser/ui/bookmarks/brave_bookmark_context_menu_controller_unittest.cc",
"//brave/chromium_src/components/metrics/enabled_state_provider_unittest.cc",
"//brave/chromium_src/components/search_engines/brave_template_url_prepopulate_data_unittest.cc",
"//brave/chromium_src/components/search_engines/brave_template_url_service_util_unittest.cc",
"//brave/chromium_src/components/version_info/brave_version_info_unittest.cc",
Expand Down

0 comments on commit 6e9931e

Please sign in to comment.