Index: chrome/common/extensions/features/complex_feature_provider_unittest.cc |
diff --git a/chrome/common/extensions/features/complex_feature_provider_unittest.cc b/chrome/common/extensions/features/complex_feature_provider_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..235b4fb411a0db6118c751ef415891b187e08c4d |
--- /dev/null |
+++ b/chrome/common/extensions/features/complex_feature_provider_unittest.cc |
@@ -0,0 +1,67 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/common/extensions/features/complex_feature_provider.h" |
+ |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+using chrome::VersionInfo; |
+using extensions::Extension; |
+using extensions::Feature; |
+using extensions::ComplexFeatureProvider; |
+ |
+TEST(ComplexFeatureProvider, ArrayRule) { |
+ scoped_ptr<DictionaryValue> value(new DictionaryValue()); |
+ 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!
|
+ |
+ DictionaryValue* rule1 = new DictionaryValue(); |
+ ListValue* extension_types = new ListValue(); |
+ extension_types->Append(Value::CreateStringValue("extension")); |
+ rule1->Set("extension_types", extension_types); |
+ rule1->SetString("channel", "beta"); |
+ feature1->Append(rule1); |
+ |
+ DictionaryValue* rule2 = new DictionaryValue(); |
+ extension_types = new ListValue(); |
+ extension_types->Append(Value::CreateStringValue("packaged_app")); |
+ rule2->Set("extension_types", extension_types); |
+ rule2->SetString("channel", "beta"); |
+ feature1->Append(rule2); |
+ |
+ value->Set("feature1", feature1); |
+ |
+ scoped_ptr<ComplexFeatureProvider> provider( |
+ new ComplexFeatureProvider(value.get())); |
+ |
+ Feature *feature = provider->GetFeature("feature1"); |
+ EXPECT_TRUE(feature); |
+ |
+ // Make sure both rules are applied correctly. |
+ { |
+ Feature::ScopedCurrentChannel current_channel(VersionInfo::CHANNEL_BETA); |
+ EXPECT_EQ(Feature::IS_AVAILABLE, feature->IsAvailableToManifest( |
+ "1", |
+ Extension::TYPE_EXTENSION, |
+ Feature::UNSPECIFIED_LOCATION, |
+ Feature::UNSPECIFIED_PLATFORM).result()); |
+ EXPECT_EQ(Feature::IS_AVAILABLE, feature->IsAvailableToManifest( |
+ "2", |
+ Extension::TYPE_LEGACY_PACKAGED_APP, |
+ Feature::UNSPECIFIED_LOCATION, |
+ Feature::UNSPECIFIED_PLATFORM).result()); |
+ } |
+ { |
+ Feature::ScopedCurrentChannel current_channel(VersionInfo::CHANNEL_STABLE); |
+ EXPECT_NE(Feature::IS_AVAILABLE, feature->IsAvailableToManifest( |
+ "1", |
+ Extension::TYPE_EXTENSION, |
+ Feature::UNSPECIFIED_LOCATION, |
+ Feature::UNSPECIFIED_PLATFORM).result()); |
+ EXPECT_NE(Feature::IS_AVAILABLE, feature->IsAvailableToManifest( |
+ "2", |
+ Extension::TYPE_LEGACY_PACKAGED_APP, |
+ Feature::UNSPECIFIED_LOCATION, |
+ Feature::UNSPECIFIED_PLATFORM).result()); |
+ } |
+} |