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