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

Unified Diff: components/arc/arc_util_unittest.cc

Issue 2648213004: Migrate --enable-arc and --arc-available part 1. (Closed)
Patch Set: address comments. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/arc/arc_util.cc ('k') | components/arc/intent_helper/arc_intent_helper_bridge.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..b3fff189f38516d1a8a9152bb41b98afb7b6eceb
--- /dev/null
+++ b/components/arc/arc_util_unittest.cc
@@ -0,0 +1,84 @@
+// 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_feature_list.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace arc {
+namespace {
+
+// If an instance is created, based on the value passed to the consturctor,
+// EnableARC feature is enabled/disabled in the scope.
+class ScopedArcFeature {
+ public:
+ explicit ScopedArcFeature(bool enabled) {
+ constexpr char kArcFeatureName[] = "EnableARC";
+ if (enabled) {
+ feature_list.InitFromCommandLine(kArcFeatureName, std::string());
+ } else {
+ feature_list.InitFromCommandLine(std::string(), kArcFeatureName);
+ }
+ }
+ ~ScopedArcFeature() = default;
+
+ private:
+ base::test::ScopedFeatureList feature_list;
+ DISALLOW_COPY_AND_ASSIGN(ScopedArcFeature);
+};
+
+using ArcUtilTest = testing::Test;
+
+// Test --arc-available with EnableARC feature combination.
+TEST_F(ArcUtilTest, IsArcAvailable_Installed) {
+ auto* command_line = base::CommandLine::ForCurrentProcess();
+
+ // If ARC is not installed, IsArcAvailable() should return false,
+ // regardless of EnableARC feature.
+ command_line->InitFromArgv({""});
+
+ // Not available, by-default.
+ EXPECT_FALSE(IsArcAvailable());
+
+ {
+ ScopedArcFeature feature(true);
+ EXPECT_FALSE(IsArcAvailable());
+ }
+ {
+ ScopedArcFeature feature(false);
+ 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());
+
+ {
+ ScopedArcFeature feature(true);
+ EXPECT_TRUE(IsArcAvailable());
+ }
+ {
+ ScopedArcFeature feature(false);
+ EXPECT_FALSE(IsArcAvailable());
+ }
+}
+
+TEST_F(ArcUtilTest, IsArcAvailable_OfficialSupport) {
+ // Regardless of FeatureList, IsArcAvailable() should return true.
+ auto* command_line = base::CommandLine::ForCurrentProcess();
+ command_line->InitFromArgv({"", "--enable-arc"});
+ EXPECT_TRUE(IsArcAvailable());
+}
+
+} // namespace
+} // namespace arc
« no previous file with comments | « components/arc/arc_util.cc ('k') | components/arc/intent_helper/arc_intent_helper_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698