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

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

Issue 22299009: Move channel-related (Chrome-specific) global state out of Feature. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/common/extensions/features/simple_feature.h" 5 #include "chrome/common/extensions/features/simple_feature.h"
6 6
7 #include "chrome/common/extensions/features/feature_channel.h"
7 #include "chrome/common/extensions/value_builder.h" 8 #include "chrome/common/extensions/value_builder.h"
8 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
9 10
10 using chrome::VersionInfo; 11 using chrome::VersionInfo;
11 using extensions::DictionaryBuilder; 12 using extensions::DictionaryBuilder;
12 using extensions::Extension; 13 using extensions::Extension;
13 using extensions::Feature; 14 using extensions::Feature;
14 using extensions::ListBuilder; 15 using extensions::ListBuilder;
15 using extensions::Manifest; 16 using extensions::Manifest;
17 using extensions::ScopedCurrentChannel;
16 using extensions::SimpleFeature; 18 using extensions::SimpleFeature;
17 19
18 namespace { 20 namespace {
19 21
20 struct IsAvailableTestData { 22 struct IsAvailableTestData {
21 std::string extension_id; 23 std::string extension_id;
22 Manifest::Type extension_type; 24 Manifest::Type extension_type;
23 Feature::Location location; 25 Feature::Location location;
24 Feature::Platform platform; 26 Feature::Platform platform;
25 int manifest_version; 27 int manifest_version;
26 Feature::AvailabilityResult expected_result; 28 Feature::AvailabilityResult expected_result;
27 }; 29 };
28 30
29 class ExtensionSimpleFeatureTest : public testing::Test { 31 class ExtensionSimpleFeatureTest : public testing::Test {
30 protected: 32 protected:
31 ExtensionSimpleFeatureTest() 33 ExtensionSimpleFeatureTest()
32 : current_channel_(VersionInfo::CHANNEL_UNKNOWN) {} 34 : current_channel_(VersionInfo::CHANNEL_UNKNOWN) {}
33 virtual ~ExtensionSimpleFeatureTest() {} 35 virtual ~ExtensionSimpleFeatureTest() {}
34 36
35 private: 37 private:
36 Feature::ScopedCurrentChannel current_channel_; 38 ScopedCurrentChannel current_channel_;
37 }; 39 };
38 40
39 TEST_F(ExtensionSimpleFeatureTest, IsAvailableNullCase) { 41 TEST_F(ExtensionSimpleFeatureTest, IsAvailableNullCase) {
40 const IsAvailableTestData tests[] = { 42 const IsAvailableTestData tests[] = {
41 { "", Manifest::TYPE_UNKNOWN, 43 { "", Manifest::TYPE_UNKNOWN,
42 Feature::UNSPECIFIED_LOCATION, Feature::UNSPECIFIED_PLATFORM, -1, 44 Feature::UNSPECIFIED_LOCATION, Feature::UNSPECIFIED_PLATFORM, -1,
43 Feature::IS_AVAILABLE }, 45 Feature::IS_AVAILABLE },
44 { "random-extension", Manifest::TYPE_UNKNOWN, 46 { "random-extension", Manifest::TYPE_UNKNOWN,
45 Feature::UNSPECIFIED_LOCATION, Feature::UNSPECIFIED_PLATFORM, -1, 47 Feature::UNSPECIFIED_LOCATION, Feature::UNSPECIFIED_PLATFORM, -1,
46 Feature::IS_AVAILABLE }, 48 Feature::IS_AVAILABLE },
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 feature2.set_min_manifest_version(0); 529 feature2.set_min_manifest_version(0);
528 EXPECT_FALSE(feature2.Equals(feature)); 530 EXPECT_FALSE(feature2.Equals(feature));
529 531
530 feature2 = feature; 532 feature2 = feature;
531 feature2.set_max_manifest_version(0); 533 feature2.set_max_manifest_version(0);
532 EXPECT_FALSE(feature2.Equals(feature)); 534 EXPECT_FALSE(feature2.Equals(feature));
533 } 535 }
534 536
535 Feature::AvailabilityResult IsAvailableInChannel( 537 Feature::AvailabilityResult IsAvailableInChannel(
536 const std::string& channel, VersionInfo::Channel channel_for_testing) { 538 const std::string& channel, VersionInfo::Channel channel_for_testing) {
537 Feature::ScopedCurrentChannel current_channel(channel_for_testing); 539 ScopedCurrentChannel current_channel(channel_for_testing);
538 540
539 SimpleFeature feature; 541 SimpleFeature feature;
540 if (!channel.empty()) { 542 if (!channel.empty()) {
541 base::DictionaryValue feature_value; 543 base::DictionaryValue feature_value;
542 feature_value.SetString("channel", channel); 544 feature_value.SetString("channel", channel);
543 feature.Parse(&feature_value); 545 feature.Parse(&feature_value);
544 } 546 }
545 547
546 return feature.IsAvailableToManifest( 548 return feature.IsAvailableToManifest(
547 "random-extension", 549 "random-extension",
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 IsAvailableInChannel("trunk", VersionInfo::CHANNEL_CANARY)); 609 IsAvailableInChannel("trunk", VersionInfo::CHANNEL_CANARY));
608 EXPECT_EQ(Feature::UNSUPPORTED_CHANNEL, 610 EXPECT_EQ(Feature::UNSUPPORTED_CHANNEL,
609 IsAvailableInChannel("trunk", VersionInfo::CHANNEL_DEV)); 611 IsAvailableInChannel("trunk", VersionInfo::CHANNEL_DEV));
610 EXPECT_EQ(Feature::UNSUPPORTED_CHANNEL, 612 EXPECT_EQ(Feature::UNSUPPORTED_CHANNEL,
611 IsAvailableInChannel("trunk", VersionInfo::CHANNEL_BETA)); 613 IsAvailableInChannel("trunk", VersionInfo::CHANNEL_BETA));
612 EXPECT_EQ(Feature::UNSUPPORTED_CHANNEL, 614 EXPECT_EQ(Feature::UNSUPPORTED_CHANNEL,
613 IsAvailableInChannel("trunk", VersionInfo::CHANNEL_STABLE)); 615 IsAvailableInChannel("trunk", VersionInfo::CHANNEL_STABLE));
614 } 616 }
615 617
616 } // namespace 618 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698