Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/common/extensions/features/complex_feature_provider.h" | |
| 6 | |
| 7 #include "testing/gtest/include/gtest/gtest.h" | |
| 8 | |
| 9 using chrome::VersionInfo; | |
| 10 using extensions::Extension; | |
| 11 using extensions::Feature; | |
| 12 using extensions::ComplexFeatureProvider; | |
| 13 | |
| 14 TEST(ComplexFeatureProvider, ArrayRule) { | |
| 15 scoped_ptr<DictionaryValue> value(new DictionaryValue()); | |
| 16 ListValue* feature1 = new ListValue(); | |
|
not at google - send to devlin
2012/12/12 17:42:41
note: handy classes for these kind of tests is the
justinlin
2012/12/14 12:26:26
Done. Awesome, thanks!
| |
| 17 | |
| 18 DictionaryValue* rule1 = new DictionaryValue(); | |
| 19 ListValue* extension_types = new ListValue(); | |
| 20 extension_types->Append(Value::CreateStringValue("extension")); | |
| 21 rule1->Set("extension_types", extension_types); | |
| 22 rule1->SetString("channel", "beta"); | |
| 23 feature1->Append(rule1); | |
| 24 | |
| 25 DictionaryValue* rule2 = new DictionaryValue(); | |
| 26 extension_types = new ListValue(); | |
| 27 extension_types->Append(Value::CreateStringValue("packaged_app")); | |
| 28 rule2->Set("extension_types", extension_types); | |
| 29 rule2->SetString("channel", "beta"); | |
| 30 feature1->Append(rule2); | |
| 31 | |
| 32 value->Set("feature1", feature1); | |
| 33 | |
| 34 scoped_ptr<ComplexFeatureProvider> provider( | |
| 35 new ComplexFeatureProvider(value.get())); | |
| 36 | |
| 37 Feature *feature = provider->GetFeature("feature1"); | |
| 38 EXPECT_TRUE(feature); | |
| 39 | |
| 40 // Make sure both rules are applied correctly. | |
| 41 { | |
| 42 Feature::ScopedCurrentChannel current_channel(VersionInfo::CHANNEL_BETA); | |
| 43 EXPECT_EQ(Feature::IS_AVAILABLE, feature->IsAvailableToManifest( | |
| 44 "1", | |
| 45 Extension::TYPE_EXTENSION, | |
| 46 Feature::UNSPECIFIED_LOCATION, | |
| 47 Feature::UNSPECIFIED_PLATFORM).result()); | |
| 48 EXPECT_EQ(Feature::IS_AVAILABLE, feature->IsAvailableToManifest( | |
| 49 "2", | |
| 50 Extension::TYPE_LEGACY_PACKAGED_APP, | |
| 51 Feature::UNSPECIFIED_LOCATION, | |
| 52 Feature::UNSPECIFIED_PLATFORM).result()); | |
| 53 } | |
| 54 { | |
| 55 Feature::ScopedCurrentChannel current_channel(VersionInfo::CHANNEL_STABLE); | |
| 56 EXPECT_NE(Feature::IS_AVAILABLE, feature->IsAvailableToManifest( | |
| 57 "1", | |
| 58 Extension::TYPE_EXTENSION, | |
| 59 Feature::UNSPECIFIED_LOCATION, | |
| 60 Feature::UNSPECIFIED_PLATFORM).result()); | |
| 61 EXPECT_NE(Feature::IS_AVAILABLE, feature->IsAvailableToManifest( | |
| 62 "2", | |
| 63 Extension::TYPE_LEGACY_PACKAGED_APP, | |
| 64 Feature::UNSPECIFIED_LOCATION, | |
| 65 Feature::UNSPECIFIED_PLATFORM).result()); | |
| 66 } | |
| 67 } | |
| OLD | NEW |