| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 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. |
| 4 |
| 5 #include "components/arc/arc_util.h" |
| 6 |
| 7 #include <memory> |
| 8 |
| 9 #include "base/macros.h" |
| 10 #include "base/memory/ptr_util.h" |
| 11 #include "base/test/scoped_command_line.h" |
| 12 #include "base/test/scoped_feature_list.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 |
| 15 namespace arc { |
| 16 namespace util { |
| 17 |
| 18 class ArcUtilTest : public testing::Test { |
| 19 public: |
| 20 ArcUtilTest() = default; |
| 21 ~ArcUtilTest() override = default; |
| 22 |
| 23 void SetUp() override { |
| 24 scoped_command_line_ = base::MakeUnique<base::test::ScopedCommandLine>(); |
| 25 } |
| 26 |
| 27 void TearDown() override { scoped_command_line_.reset(); } |
| 28 |
| 29 private: |
| 30 std::unique_ptr<base::test::ScopedCommandLine> scoped_command_line_; |
| 31 |
| 32 DISALLOW_COPY_AND_ASSIGN(ArcUtilTest); |
| 33 }; |
| 34 |
| 35 TEST_F(ArcUtilTest, IsArcEnabled) { |
| 36 auto* command_line = base::CommandLine::ForCurrentProcess(); |
| 37 command_line->InitFromArgv({""}); |
| 38 { |
| 39 base::test::ScopedFeatureList feature_list; |
| 40 feature_list.InitFromCommandLine("EnableARC", ""); |
| 41 EXPECT_FALSE(IsArcEnabled()); |
| 42 } |
| 43 { |
| 44 base::test::ScopedFeatureList feature_list; |
| 45 feature_list.InitFromCommandLine("", "EnableARC"); |
| 46 EXPECT_FALSE(IsArcEnabled()); |
| 47 } |
| 48 |
| 49 command_line->InitFromArgv({"", "--arc-available"}); |
| 50 { |
| 51 base::test::ScopedFeatureList feature_list; |
| 52 feature_list.InitFromCommandLine("EnableARC", ""); |
| 53 EXPECT_TRUE(IsArcEnabled()); |
| 54 } |
| 55 { |
| 56 base::test::ScopedFeatureList feature_list; |
| 57 feature_list.InitFromCommandLine("", "EnableARC"); |
| 58 EXPECT_FALSE(IsArcEnabled()); |
| 59 } |
| 60 |
| 61 command_line->InitFromArgv({"", "--enable-arc"}); |
| 62 EXPECT_TRUE(IsArcEnabled()); |
| 63 } |
| 64 |
| 65 TEST_F(ArcUtilTest, IsArcAvailable) { |
| 66 auto* command_line = base::CommandLine::ForCurrentProcess(); |
| 67 command_line->InitFromArgv({""}); |
| 68 EXPECT_FALSE(IsArcAvailable()); |
| 69 |
| 70 command_line->InitFromArgv({"", "--arc-available"}); |
| 71 EXPECT_TRUE(IsArcAvailable()); |
| 72 } |
| 73 |
| 74 // TODO(hidehiko): Add test for IsArcKioskMode(). |
| 75 // It depends on UserManager, but a utility to inject fake instance is |
| 76 // available only in chrome/. To use it in components/, refactoring is needed. |
| 77 |
| 78 TEST_F(ArcUtilTest, IsOptInVerificationDisabled) { |
| 79 auto* command_line = base::CommandLine::ForCurrentProcess(); |
| 80 command_line->InitFromArgv({""}); |
| 81 EXPECT_FALSE(IsOptInVerificationDisabled()); |
| 82 |
| 83 command_line->InitFromArgv({"", "--disable-arc-opt-in-verification"}); |
| 84 EXPECT_TRUE(IsOptInVerificationDisabled()); |
| 85 } |
| 86 |
| 87 } // namespace util |
| 88 } // namespace arc |
| OLD | NEW |