Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1407)

Side by Side Diff: components/arc/arc_util_unittest.cc

Issue 2648213004: Migrate --enable-arc and --arc-available part 1. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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/command_line.h"
10 #include "base/macros.h"
11 #include "base/memory/ptr_util.h"
12 #include "base/test/scoped_command_line.h"
13 #include "base/test/scoped_feature_list.h"
14 #include "testing/gtest/include/gtest/gtest.h"
15
16 namespace arc {
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 --arc-available with EnableARC feature combination.
36 TEST_F(ArcUtilTest, IsArcAvailable_Installed) {
hidehiko 2017/01/24 10:57:36 Note: these sub-test are named after the discussio
37 auto* command_line = base::CommandLine::ForCurrentProcess();
38
39 // If ARC is not installed, IsArcAvailable() should return false,
40 // regardless of EnableARC feature.
41 command_line->InitFromArgv({""});
42
43 // Not availble, by-default.
44 EXPECT_FALSE(IsArcAvailable());
45
46 {
47 base::test::ScopedFeatureList feature_list;
48 feature_list.InitFromCommandLine("EnableARC", "");
49 EXPECT_FALSE(IsArcAvailable());
50 }
51 {
52 base::test::ScopedFeatureList feature_list;
53 feature_list.InitFromCommandLine("", "EnableARC");
54 EXPECT_FALSE(IsArcAvailable());
55 }
56
57 // If ARC is installed, IsArcAvailable() should return true when EnableARC
58 // feature is set.
59 command_line->InitFromArgv({"", "--arc-available"});
60
61 // Not available, by-default, too.
62 EXPECT_FALSE(IsArcAvailable());
63
64 {
65 base::test::ScopedFeatureList feature_list;
66 feature_list.InitFromCommandLine("EnableARC", "");
67 EXPECT_TRUE(IsArcAvailable());
68 }
69 {
70 base::test::ScopedFeatureList feature_list;
71 feature_list.InitFromCommandLine("", "EnableARC");
72 EXPECT_FALSE(IsArcAvailable());
73 }
74 }
75
76 TEST_F(ArcUtilTest, IsArcAvailable_OfficialSupport) {
77 // Regardless of FeatureList, IsArcAvailable() should return true.
78 auto* command_line = base::CommandLine::ForCurrentProcess();
79 command_line->InitFromArgv({"", "--enable-arc"});
80 EXPECT_TRUE(IsArcAvailable());
81 }
82
83 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698