blob: 17280b3ee5ea95e9b6fb4d8995df2085e43c0bc5 [file] [log] [blame]
// Copyright 2019 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 "components/search/ntp_features.h"
#include "base/test/scoped_feature_list.h"
#include "base/time/time.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace ntp_features {
TEST(NTPFeaturesTest, ModulesLoadTimeout) {
base::test::ScopedFeatureList scoped_feature_list_;
// The default value can be overridden.
scoped_feature_list_.InitWithFeaturesAndParameters(
{{kModules, {{kNtpModulesLoadTimeoutMillisecondsParam, "123"}}}}, {});
base::TimeDelta timeout = GetModulesLoadTimeout();
EXPECT_EQ(123, timeout.InMilliseconds());
// If the timeout is not parsable to an unsigned integer, the default value is
// used.
scoped_feature_list_.Reset();
scoped_feature_list_.InitWithFeaturesAndParameters(
{{kModules, {{kNtpModulesLoadTimeoutMillisecondsParam, "j"}}}}, {});
timeout = GetModulesLoadTimeout();
EXPECT_EQ(3, timeout.InSeconds());
}
} // namespace ntp_features