OLD | NEW |
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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
874 std::unique_ptr<ComplexFeature> complex_feature; | 874 std::unique_ptr<ComplexFeature> complex_feature; |
875 { | 875 { |
876 std::unique_ptr<SimpleFeature> feature1(CreateFeature<SimpleFeature>()); | 876 std::unique_ptr<SimpleFeature> feature1(CreateFeature<SimpleFeature>()); |
877 feature1->channel_.reset( | 877 feature1->channel_.reset( |
878 new version_info::Channel(version_info::Channel::BETA)); | 878 new version_info::Channel(version_info::Channel::BETA)); |
879 feature1->extension_types_.push_back(Manifest::TYPE_EXTENSION); | 879 feature1->extension_types_.push_back(Manifest::TYPE_EXTENSION); |
880 std::unique_ptr<SimpleFeature> feature2(CreateFeature<SimpleFeature>()); | 880 std::unique_ptr<SimpleFeature> feature2(CreateFeature<SimpleFeature>()); |
881 feature2->channel_.reset( | 881 feature2->channel_.reset( |
882 new version_info::Channel(version_info::Channel::BETA)); | 882 new version_info::Channel(version_info::Channel::BETA)); |
883 feature2->extension_types_.push_back(Manifest::TYPE_LEGACY_PACKAGED_APP); | 883 feature2->extension_types_.push_back(Manifest::TYPE_LEGACY_PACKAGED_APP); |
884 std::unique_ptr<ComplexFeature::FeatureList> list( | 884 std::vector<Feature*> list; |
885 new ComplexFeature::FeatureList()); | 885 list.push_back(feature1.release()); |
886 list->push_back(std::move(feature1)); | 886 list.push_back(feature2.release()); |
887 list->push_back(std::move(feature2)); | 887 complex_feature.reset(new ComplexFeature(&list)); |
888 complex_feature.reset(new ComplexFeature(std::move(list))); | |
889 } | 888 } |
890 | 889 |
891 Feature* feature = static_cast<Feature*>(complex_feature.get()); | 890 Feature* feature = static_cast<Feature*>(complex_feature.get()); |
892 // Make sure both rules are applied correctly. | 891 // Make sure both rules are applied correctly. |
893 { | 892 { |
894 ScopedCurrentChannel current_channel(version_info::Channel::BETA); | 893 ScopedCurrentChannel current_channel(version_info::Channel::BETA); |
895 EXPECT_EQ( | 894 EXPECT_EQ( |
896 Feature::IS_AVAILABLE, | 895 Feature::IS_AVAILABLE, |
897 feature->IsAvailableToManifest("1", | 896 feature->IsAvailableToManifest("1", |
898 Manifest::TYPE_EXTENSION, | 897 Manifest::TYPE_EXTENSION, |
(...skipping 30 matching lines...) Expand all Loading... |
929 // Rule: "extension", channel trunk. | 928 // Rule: "extension", channel trunk. |
930 std::unique_ptr<SimpleFeature> feature1(CreateFeature<SimpleFeature>()); | 929 std::unique_ptr<SimpleFeature> feature1(CreateFeature<SimpleFeature>()); |
931 feature1->channel_.reset( | 930 feature1->channel_.reset( |
932 new version_info::Channel(version_info::Channel::UNKNOWN)); | 931 new version_info::Channel(version_info::Channel::UNKNOWN)); |
933 feature1->extension_types_.push_back(Manifest::TYPE_EXTENSION); | 932 feature1->extension_types_.push_back(Manifest::TYPE_EXTENSION); |
934 std::unique_ptr<SimpleFeature> feature2(CreateFeature<SimpleFeature>()); | 933 std::unique_ptr<SimpleFeature> feature2(CreateFeature<SimpleFeature>()); |
935 // Rule: "legacy_packaged_app", channel stable. | 934 // Rule: "legacy_packaged_app", channel stable. |
936 feature2->channel_.reset( | 935 feature2->channel_.reset( |
937 new version_info::Channel(version_info::Channel::STABLE)); | 936 new version_info::Channel(version_info::Channel::STABLE)); |
938 feature2->extension_types_.push_back(Manifest::TYPE_LEGACY_PACKAGED_APP); | 937 feature2->extension_types_.push_back(Manifest::TYPE_LEGACY_PACKAGED_APP); |
939 std::unique_ptr<ComplexFeature::FeatureList> list( | 938 std::vector<Feature*> list; |
940 new ComplexFeature::FeatureList()); | 939 list.push_back(feature1.release()); |
941 list->push_back(std::move(feature1)); | 940 list.push_back(feature2.release()); |
942 list->push_back(std::move(feature2)); | 941 complex_feature.reset(new ComplexFeature(&list)); |
943 complex_feature.reset(new ComplexFeature(std::move(list))); | |
944 } | 942 } |
945 | 943 |
946 Feature* feature = static_cast<Feature*>(complex_feature.get()); | 944 Feature* feature = static_cast<Feature*>(complex_feature.get()); |
947 { | 945 { |
948 ScopedCurrentChannel current_channel(version_info::Channel::UNKNOWN); | 946 ScopedCurrentChannel current_channel(version_info::Channel::UNKNOWN); |
949 EXPECT_EQ(Feature::IS_AVAILABLE, | 947 EXPECT_EQ(Feature::IS_AVAILABLE, |
950 feature | 948 feature |
951 ->IsAvailableToManifest("1", Manifest::TYPE_EXTENSION, | 949 ->IsAvailableToManifest("1", Manifest::TYPE_EXTENSION, |
952 Manifest::INVALID_LOCATION, | 950 Manifest::INVALID_LOCATION, |
953 Feature::UNSPECIFIED_PLATFORM) | 951 Feature::UNSPECIFIED_PLATFORM) |
(...skipping 13 matching lines...) Expand all Loading... |
967 EXPECT_NE(Feature::IS_AVAILABLE, | 965 EXPECT_NE(Feature::IS_AVAILABLE, |
968 feature | 966 feature |
969 ->IsAvailableToManifest("1", Manifest::TYPE_EXTENSION, | 967 ->IsAvailableToManifest("1", Manifest::TYPE_EXTENSION, |
970 Manifest::INVALID_LOCATION, | 968 Manifest::INVALID_LOCATION, |
971 Feature::UNSPECIFIED_PLATFORM) | 969 Feature::UNSPECIFIED_PLATFORM) |
972 .result()); | 970 .result()); |
973 } | 971 } |
974 } | 972 } |
975 | 973 |
976 } // namespace extensions | 974 } // namespace extensions |
OLD | NEW |