Chromium Code Reviews| 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..5fd4cdd86de3a80be8cebded22f8a490b3c7a298 |
| --- /dev/null |
| +++ b/components/arc/arc_util_unittest.cc |
| @@ -0,0 +1,83 @@ |
| +// 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/command_line.h" |
| +#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 { |
| + |
| +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
|
| + 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_; |
|
hidehiko
2017/01/25 17:54:47
Note: it turned out that test framework actually r
|
| + |
| + DISALLOW_COPY_AND_ASSIGN(ArcUtilTest); |
| +}; |
| + |
| +// Test --arc-available with EnableARC feature combination. |
| +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
|
| + auto* command_line = base::CommandLine::ForCurrentProcess(); |
| + |
| + // If ARC is not installed, IsArcAvailable() should return false, |
| + // regardless of EnableARC feature. |
| + command_line->InitFromArgv({""}); |
| + |
| + // Not availble, by-default. |
| + EXPECT_FALSE(IsArcAvailable()); |
| + |
| + { |
| + base::test::ScopedFeatureList feature_list; |
| + 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?
|
| + EXPECT_FALSE(IsArcAvailable()); |
| + } |
| + { |
| + base::test::ScopedFeatureList feature_list; |
| + 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.
|
| + EXPECT_FALSE(IsArcAvailable()); |
| + } |
| + |
| + // If ARC is installed, IsArcAvailable() should return true when EnableARC |
| + // feature is set. |
| + command_line->InitFromArgv({"", "--arc-available"}); |
| + |
| + // Not available, by-default, too. |
| + EXPECT_FALSE(IsArcAvailable()); |
| + |
| + { |
| + base::test::ScopedFeatureList feature_list; |
| + feature_list.InitFromCommandLine("EnableARC", ""); |
| + EXPECT_TRUE(IsArcAvailable()); |
| + } |
| + { |
| + base::test::ScopedFeatureList feature_list; |
| + feature_list.InitFromCommandLine("", "EnableARC"); |
| + EXPECT_FALSE(IsArcAvailable()); |
| + } |
| +} |
| + |
| +TEST_F(ArcUtilTest, IsArcAvailable_OfficialSupport) { |
|
Yusuke Sato
2017/01/24 19:02:44
same
hidehiko
2017/01/25 17:54:47
Acknowledged.
|
| + // Regardless of FeatureList, IsArcAvailable() should return true. |
| + auto* command_line = base::CommandLine::ForCurrentProcess(); |
| + command_line->InitFromArgv({"", "--enable-arc"}); |
| + EXPECT_TRUE(IsArcAvailable()); |
| +} |
| + |
| +} // namespace arc |