| Index: components/arc/arc_util_unittest.cc
|
| diff --git a/components/arc/arc_util_unittest.cc b/components/arc/arc_util_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..34e4fc26fb28eeaa242cbcb28c42b1dfdd00ef46
|
| --- /dev/null
|
| +++ b/components/arc/arc_util_unittest.cc
|
| @@ -0,0 +1,88 @@
|
| +// Copyright 2017 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/arc/arc_util.h"
|
| +
|
| +#include <memory>
|
| +
|
| +#include "base/macros.h"
|
| +#include "base/memory/ptr_util.h"
|
| +#include "base/test/scoped_command_line.h"
|
| +#include "base/test/scoped_feature_list.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +
|
| +namespace arc {
|
| +namespace util {
|
| +
|
| +class ArcUtilTest : public testing::Test {
|
| + public:
|
| + ArcUtilTest() = default;
|
| + ~ArcUtilTest() override = default;
|
| +
|
| + void SetUp() override {
|
| + scoped_command_line_ = base::MakeUnique<base::test::ScopedCommandLine>();
|
| + }
|
| +
|
| + void TearDown() override { scoped_command_line_.reset(); }
|
| +
|
| + private:
|
| + std::unique_ptr<base::test::ScopedCommandLine> scoped_command_line_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(ArcUtilTest);
|
| +};
|
| +
|
| +TEST_F(ArcUtilTest, IsArcEnabled) {
|
| + auto* command_line = base::CommandLine::ForCurrentProcess();
|
| + command_line->InitFromArgv({""});
|
| + {
|
| + base::test::ScopedFeatureList feature_list;
|
| + feature_list.InitFromCommandLine("EnableARC", "");
|
| + EXPECT_FALSE(IsArcEnabled());
|
| + }
|
| + {
|
| + base::test::ScopedFeatureList feature_list;
|
| + feature_list.InitFromCommandLine("", "EnableARC");
|
| + EXPECT_FALSE(IsArcEnabled());
|
| + }
|
| +
|
| + command_line->InitFromArgv({"", "--arc-available"});
|
| + {
|
| + base::test::ScopedFeatureList feature_list;
|
| + feature_list.InitFromCommandLine("EnableARC", "");
|
| + EXPECT_TRUE(IsArcEnabled());
|
| + }
|
| + {
|
| + base::test::ScopedFeatureList feature_list;
|
| + feature_list.InitFromCommandLine("", "EnableARC");
|
| + EXPECT_FALSE(IsArcEnabled());
|
| + }
|
| +
|
| + command_line->InitFromArgv({"", "--enable-arc"});
|
| + EXPECT_TRUE(IsArcEnabled());
|
| +}
|
| +
|
| +TEST_F(ArcUtilTest, IsArcAvailable) {
|
| + auto* command_line = base::CommandLine::ForCurrentProcess();
|
| + command_line->InitFromArgv({""});
|
| + EXPECT_FALSE(IsArcAvailable());
|
| +
|
| + command_line->InitFromArgv({"", "--arc-available"});
|
| + EXPECT_TRUE(IsArcAvailable());
|
| +}
|
| +
|
| +// TODO(hidehiko): Add test for IsArcKioskMode().
|
| +// It depends on UserManager, but a utility to inject fake instance is
|
| +// available only in chrome/. To use it in components/, refactoring is needed.
|
| +
|
| +TEST_F(ArcUtilTest, IsOptInVerificationDisabled) {
|
| + auto* command_line = base::CommandLine::ForCurrentProcess();
|
| + command_line->InitFromArgv({""});
|
| + EXPECT_FALSE(IsOptInVerificationDisabled());
|
| +
|
| + command_line->InitFromArgv({"", "--disable-arc-opt-in-verification"});
|
| + EXPECT_TRUE(IsOptInVerificationDisabled());
|
| +}
|
| +
|
| +} // namespace util
|
| +} // namespace arc
|
|
|