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

Side by Side Diff: extensions/common/features/simple_feature_unittest.cc

Issue 1054813002: Refactor ScopedCommandLineSwitch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@whitelisted
Patch Set: Created 5 years, 8 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/common/features/simple_feature.h" 5 #include "extensions/common/features/simple_feature.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "extensions/common/manifest.h" 12 #include "extensions/common/manifest.h"
13 #include "extensions/common/test/scoped_command_line_switch.h"
13 #include "extensions/common/value_builder.h" 14 #include "extensions/common/value_builder.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 16
16 namespace extensions { 17 namespace extensions {
17 18
18 namespace { 19 namespace {
19 20
20 struct IsAvailableTestData { 21 struct IsAvailableTestData {
21 std::string extension_id; 22 std::string extension_id;
22 Manifest::Type extension_type; 23 Manifest::Type extension_type;
23 Manifest::Location location; 24 Manifest::Location location;
24 Feature::Platform platform; 25 Feature::Platform platform;
25 int manifest_version; 26 int manifest_version;
26 Feature::AvailabilityResult expected_result; 27 Feature::AvailabilityResult expected_result;
27 }; 28 };
28 29
29 class ScopedCommandLineSwitch {
30 public:
31 explicit ScopedCommandLineSwitch(const std::string& arg)
32 : original_command_line_(*base::CommandLine::ForCurrentProcess()) {
33 base::CommandLine::ForCurrentProcess()->AppendSwitch(arg);
34 }
35
36 ~ScopedCommandLineSwitch() {
37 *base::CommandLine::ForCurrentProcess() = original_command_line_;
38 }
39
40 private:
41 base::CommandLine original_command_line_;
42 };
43
44 } // namespace 30 } // namespace
45 31
46 class SimpleFeatureTest : public testing::Test { 32 class SimpleFeatureTest : public testing::Test {
47 protected: 33 protected:
48 bool LocationIsAvailable(SimpleFeature::Location feature_location, 34 bool LocationIsAvailable(SimpleFeature::Location feature_location,
49 Manifest::Location manifest_location) { 35 Manifest::Location manifest_location) {
50 SimpleFeature feature; 36 SimpleFeature feature;
51 feature.set_location(feature_location); 37 feature.set_location(feature_location);
52 Feature::AvailabilityResult availability_result = 38 Feature::AvailabilityResult availability_result =
53 feature.IsAvailableToManifest(std::string(), 39 feature.IsAvailableToManifest(std::string(),
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 EXPECT_FALSE(SimpleFeature::IsIdInArray("", kIdArray, arraysize(kIdArray))); 726 EXPECT_FALSE(SimpleFeature::IsIdInArray("", kIdArray, arraysize(kIdArray)));
741 EXPECT_FALSE(SimpleFeature::IsIdInArray( 727 EXPECT_FALSE(SimpleFeature::IsIdInArray(
742 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", kIdArray, arraysize(kIdArray))); 728 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", kIdArray, arraysize(kIdArray)));
743 EXPECT_TRUE(SimpleFeature::IsIdInArray( 729 EXPECT_TRUE(SimpleFeature::IsIdInArray(
744 "bbbbccccdddddddddeeeeeeffffgghhh", kIdArray, arraysize(kIdArray))); 730 "bbbbccccdddddddddeeeeeeffffgghhh", kIdArray, arraysize(kIdArray)));
745 EXPECT_TRUE(SimpleFeature::IsIdInArray( 731 EXPECT_TRUE(SimpleFeature::IsIdInArray(
746 "aaaabbbbccccddddeeeeffffgggghhhh", kIdArray, arraysize(kIdArray))); 732 "aaaabbbbccccddddeeeeffffgggghhhh", kIdArray, arraysize(kIdArray)));
747 } 733 }
748 734
749 } // namespace extensions 735 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698