Commit 391a9bcd authored by Cathy Li's avatar Cathy Li Committed by Commit Bot

Block explore_sites/most_visited_client from returning when the feature is off

Change-Id: Id3998f7ae6dd0de5449a184481afd392e549b889
Bug: 1042531
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2003070
Commit-Queue: Cathy Li <chili@chromium.org>
Reviewed-by: default avatarJustin DeWitt <dewittj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732586}
parent 298a4038
......@@ -4,8 +4,9 @@
#include "chrome/browser/android/explore_sites/most_visited_client.h"
#include "base/feature_list.h"
#include "base/memory/ptr_util.h"
#include "chrome/browser/android/explore_sites/explore_sites_feature.h"
#include "chrome/browser/android/chrome_feature_list.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
......@@ -13,6 +14,9 @@
namespace explore_sites {
std::unique_ptr<MostVisitedClient> MostVisitedClient::Create() {
if (!base::FeatureList::IsEnabled(chrome::android::kExploreSites))
return nullptr;
// note: wrap_unique is used because the constructor is private.
return base::WrapUnique(new MostVisitedClient());
}
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/android/explore_sites/most_visited_client.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/android/chrome_feature_list.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace explore_sites {
TEST(MostVisitedClientTest, ReturnsNullWhenExploreSitesDisabled) {
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndDisableFeature(chrome::android::kExploreSites);
EXPECT_EQ(nullptr, MostVisitedClient::Create());
}
TEST(MostVisitedClientTest, ReturnsNonNullWhenExploreSitesEnabled) {
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndEnableFeature(chrome::android::kExploreSites);
EXPECT_NE(nullptr, MostVisitedClient::Create());
}
} // namespace explore_sites
......@@ -2976,6 +2976,7 @@ test("unit_tests") {
"../browser/android/explore_sites/image_helper_unittest.cc",
"../browser/android/explore_sites/import_catalog_task_unittest.cc",
"../browser/android/explore_sites/increment_shown_count_task_unittest.cc",
"../browser/android/explore_sites/most_visited_client_unittest.cc",
"../browser/android/explore_sites/ntp_json_fetcher_unittest.cc",
"../browser/android/explore_sites/record_site_click_task_unittest.cc",
"../browser/android/history_report/data_observer_unittest.cc",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment