| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/arc/arc_util.h" | 5 #include "components/arc/arc_util.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 } | 29 } |
| 30 ~ScopedArcFeature() = default; | 30 ~ScopedArcFeature() = default; |
| 31 | 31 |
| 32 private: | 32 private: |
| 33 base::test::ScopedFeatureList feature_list; | 33 base::test::ScopedFeatureList feature_list; |
| 34 DISALLOW_COPY_AND_ASSIGN(ScopedArcFeature); | 34 DISALLOW_COPY_AND_ASSIGN(ScopedArcFeature); |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 using ArcUtilTest = testing::Test; | 37 using ArcUtilTest = testing::Test; |
| 38 | 38 |
| 39 TEST_F(ArcUtilTest, IsArcAvailable_None) { |
| 40 auto* command_line = base::CommandLine::ForCurrentProcess(); |
| 41 |
| 42 command_line->InitFromArgv({"", "--arc-availability=none"}); |
| 43 EXPECT_FALSE(IsArcAvailable()); |
| 44 |
| 45 // If --arc-availability flag is set to "none", even if Finch experiment is |
| 46 // turned on, ARC cannot be used. |
| 47 { |
| 48 ScopedArcFeature feature(true); |
| 49 EXPECT_FALSE(IsArcAvailable()); |
| 50 } |
| 51 } |
| 52 |
| 39 // Test --arc-available with EnableARC feature combination. | 53 // Test --arc-available with EnableARC feature combination. |
| 40 TEST_F(ArcUtilTest, IsArcAvailable_Installed) { | 54 TEST_F(ArcUtilTest, IsArcAvailable_Installed) { |
| 41 auto* command_line = base::CommandLine::ForCurrentProcess(); | 55 auto* command_line = base::CommandLine::ForCurrentProcess(); |
| 42 | 56 |
| 43 // If ARC is not installed, IsArcAvailable() should return false, | 57 // If ARC is not installed, IsArcAvailable() should return false, |
| 44 // regardless of EnableARC feature. | 58 // regardless of EnableARC feature. |
| 45 command_line->InitFromArgv({""}); | 59 command_line->InitFromArgv({""}); |
| 46 | 60 |
| 47 // Not available, by-default. | 61 // Not available, by-default. |
| 48 EXPECT_FALSE(IsArcAvailable()); | 62 EXPECT_FALSE(IsArcAvailable()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 64 EXPECT_FALSE(IsArcAvailable()); | 78 EXPECT_FALSE(IsArcAvailable()); |
| 65 | 79 |
| 66 { | 80 { |
| 67 ScopedArcFeature feature(true); | 81 ScopedArcFeature feature(true); |
| 68 EXPECT_TRUE(IsArcAvailable()); | 82 EXPECT_TRUE(IsArcAvailable()); |
| 69 } | 83 } |
| 70 { | 84 { |
| 71 ScopedArcFeature feature(false); | 85 ScopedArcFeature feature(false); |
| 72 EXPECT_FALSE(IsArcAvailable()); | 86 EXPECT_FALSE(IsArcAvailable()); |
| 73 } | 87 } |
| 88 |
| 89 // If ARC is installed, IsArcAvailable() should return true when EnableARC |
| 90 // feature is set. |
| 91 command_line->InitFromArgv({"", "--arc-availability=installed"}); |
| 92 |
| 93 // Not available, by-default, too. |
| 94 EXPECT_FALSE(IsArcAvailable()); |
| 95 |
| 96 { |
| 97 ScopedArcFeature feature(true); |
| 98 EXPECT_TRUE(IsArcAvailable()); |
| 99 } |
| 100 { |
| 101 ScopedArcFeature feature(false); |
| 102 EXPECT_FALSE(IsArcAvailable()); |
| 103 } |
| 74 } | 104 } |
| 75 | 105 |
| 76 TEST_F(ArcUtilTest, IsArcAvailable_OfficialSupport) { | 106 TEST_F(ArcUtilTest, IsArcAvailable_OfficiallySupported) { |
| 77 // Regardless of FeatureList, IsArcAvailable() should return true. | 107 // Regardless of FeatureList, IsArcAvailable() should return true. |
| 78 auto* command_line = base::CommandLine::ForCurrentProcess(); | 108 auto* command_line = base::CommandLine::ForCurrentProcess(); |
| 79 command_line->InitFromArgv({"", "--enable-arc"}); | 109 command_line->InitFromArgv({"", "--enable-arc"}); |
| 80 EXPECT_TRUE(IsArcAvailable()); | 110 EXPECT_TRUE(IsArcAvailable()); |
| 111 |
| 112 command_line->InitFromArgv({"", "--arc-availability=officially-supported"}); |
| 113 EXPECT_TRUE(IsArcAvailable()); |
| 81 } | 114 } |
| 82 | 115 |
| 83 // TODO(hidehiko): Add test for IsArcKioskMode(). | 116 // TODO(hidehiko): Add test for IsArcKioskMode(). |
| 84 // It depends on UserManager, but a utility to inject fake instance is | 117 // It depends on UserManager, but a utility to inject fake instance is |
| 85 // available only in chrome/. To use it in components/, refactoring is needed. | 118 // available only in chrome/. To use it in components/, refactoring is needed. |
| 86 | 119 |
| 87 TEST_F(ArcUtilTest, IsArcOptInVerificationDisabled) { | 120 TEST_F(ArcUtilTest, IsArcOptInVerificationDisabled) { |
| 88 auto* command_line = base::CommandLine::ForCurrentProcess(); | 121 auto* command_line = base::CommandLine::ForCurrentProcess(); |
| 89 command_line->InitFromArgv({""}); | 122 command_line->InitFromArgv({""}); |
| 90 EXPECT_FALSE(IsArcOptInVerificationDisabled()); | 123 EXPECT_FALSE(IsArcOptInVerificationDisabled()); |
| 91 | 124 |
| 92 command_line->InitFromArgv({"", "--disable-arc-opt-in-verification"}); | 125 command_line->InitFromArgv({"", "--disable-arc-opt-in-verification"}); |
| 93 EXPECT_TRUE(IsArcOptInVerificationDisabled()); | 126 EXPECT_TRUE(IsArcOptInVerificationDisabled()); |
| 94 } | 127 } |
| 95 | 128 |
| 96 } // namespace | 129 } // namespace |
| 97 } // namespace arc | 130 } // namespace arc |
| OLD | NEW |