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/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 { | |
Yusuke Sato
2017/01/24 19:02:44
nit: put this in an anonymous namespace
hidehiko
2017/01/25 17:54:47
Can I keep it as is for consistency?
IIUC, most of
Yusuke Sato
2017/01/25 18:59:31
Should we keep doing that?
https://google.github.
hidehiko
2017/01/26 02:36:59
I see. So,
- done in this file only.
- other tests
| |
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_; | |
hidehiko
2017/01/25 17:54:47
Note: it turned out that test framework actually r
| |
31 | |
32 DISALLOW_COPY_AND_ASSIGN(ArcUtilTest); | |
33 }; | |
34 | |
35 // Test --arc-available with EnableARC feature combination. | |
36 TEST_F(ArcUtilTest, IsArcAvailable_Installed) { | |
Yusuke Sato
2017/01/24 19:02:44
nit: is it common to have underscores in a test na
hidehiko
2017/01/25 17:54:47
I think yes.
https://cs.chromium.org/search/?q=TES
| |
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", ""); | |
Yusuke Sato
2017/01/24 19:02:44
* kEnableARC[] please.
* Most of us are not famili
hidehiko
2017/01/25 17:54:47
Instead, I introduced a small wrapper. WDYT?
| |
49 EXPECT_FALSE(IsArcAvailable()); | |
50 } | |
51 { | |
52 base::test::ScopedFeatureList feature_list; | |
53 feature_list.InitFromCommandLine("", "EnableARC"); | |
Yusuke Sato
2017/01/24 19:02:44
// Disable the experiment.
(here and elsewhere)
hidehiko
2017/01/25 17:54:47
Acknowledged.
| |
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) { | |
Yusuke Sato
2017/01/24 19:02:44
same
hidehiko
2017/01/25 17:54:47
Acknowledged.
| |
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 | |
OLD | NEW |