OLD | NEW |
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/feature.h" | 5 #include "chrome/common/extensions/features/feature.h" |
6 | 6 |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 | 8 |
9 using chrome::VersionInfo; | 9 using chrome::VersionInfo; |
10 using extensions::Extension; | 10 using extensions::Extension; |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 feature2.set_min_manifest_version(0); | 447 feature2.set_min_manifest_version(0); |
448 EXPECT_FALSE(feature2.Equals(feature)); | 448 EXPECT_FALSE(feature2.Equals(feature)); |
449 | 449 |
450 feature2 = feature; | 450 feature2 = feature; |
451 feature2.set_max_manifest_version(0); | 451 feature2.set_max_manifest_version(0); |
452 EXPECT_FALSE(feature2.Equals(feature)); | 452 EXPECT_FALSE(feature2.Equals(feature)); |
453 } | 453 } |
454 | 454 |
455 Feature::Availability IsAvailableInChannel( | 455 Feature::Availability IsAvailableInChannel( |
456 const std::string& channel, VersionInfo::Channel channel_for_testing) { | 456 const std::string& channel, VersionInfo::Channel channel_for_testing) { |
457 Feature::SetChannelCheckingEnabled(true); | 457 Feature::ScopedCurrentChannel current_channel(channel_for_testing); |
458 Feature::SetChannelForTesting(channel_for_testing); | |
459 | 458 |
460 Feature feature; | 459 Feature feature; |
461 if (!channel.empty()) { | 460 if (!channel.empty()) { |
462 DictionaryValue feature_value; | 461 DictionaryValue feature_value; |
463 feature_value.SetString("channel", channel); | 462 feature_value.SetString("channel", channel); |
464 feature.Parse(&feature_value); | 463 feature.Parse(&feature_value); |
465 } | 464 } |
466 | 465 |
467 Feature::Availability availability = feature.IsAvailableToManifest( | 466 return feature.IsAvailableToManifest( |
468 "random-extension", | 467 "random-extension", |
469 Extension::TYPE_UNKNOWN, | 468 Extension::TYPE_UNKNOWN, |
470 Feature::UNSPECIFIED_LOCATION, | 469 Feature::UNSPECIFIED_LOCATION, |
471 -1); | 470 -1); |
472 | |
473 Feature::ResetChannelForTesting(); | |
474 Feature::ResetChannelCheckingEnabled(); | |
475 return availability; | |
476 } | 471 } |
477 | 472 |
478 TEST(ExtensionFeatureTest, SupportedChannel) { | 473 TEST(ExtensionFeatureTest, SupportedChannel) { |
479 // stable supported. | 474 // stable supported. |
480 EXPECT_EQ(Feature::IS_AVAILABLE, | 475 EXPECT_EQ(Feature::IS_AVAILABLE, |
481 IsAvailableInChannel("stable", VersionInfo::CHANNEL_UNKNOWN)); | 476 IsAvailableInChannel("stable", VersionInfo::CHANNEL_UNKNOWN)); |
482 EXPECT_EQ(Feature::IS_AVAILABLE, | 477 EXPECT_EQ(Feature::IS_AVAILABLE, |
483 IsAvailableInChannel("stable", VersionInfo::CHANNEL_CANARY)); | 478 IsAvailableInChannel("stable", VersionInfo::CHANNEL_CANARY)); |
484 EXPECT_EQ(Feature::IS_AVAILABLE, | 479 EXPECT_EQ(Feature::IS_AVAILABLE, |
485 IsAvailableInChannel("stable", VersionInfo::CHANNEL_DEV)); | 480 IsAvailableInChannel("stable", VersionInfo::CHANNEL_DEV)); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 IsAvailableInChannel("", VersionInfo::CHANNEL_CANARY)); | 538 IsAvailableInChannel("", VersionInfo::CHANNEL_CANARY)); |
544 EXPECT_EQ(Feature::UNSUPPORTED_CHANNEL, | 539 EXPECT_EQ(Feature::UNSUPPORTED_CHANNEL, |
545 IsAvailableInChannel("", VersionInfo::CHANNEL_DEV)); | 540 IsAvailableInChannel("", VersionInfo::CHANNEL_DEV)); |
546 EXPECT_EQ(Feature::UNSUPPORTED_CHANNEL, | 541 EXPECT_EQ(Feature::UNSUPPORTED_CHANNEL, |
547 IsAvailableInChannel("", VersionInfo::CHANNEL_BETA)); | 542 IsAvailableInChannel("", VersionInfo::CHANNEL_BETA)); |
548 EXPECT_EQ(Feature::UNSUPPORTED_CHANNEL, | 543 EXPECT_EQ(Feature::UNSUPPORTED_CHANNEL, |
549 IsAvailableInChannel("", VersionInfo::CHANNEL_STABLE)); | 544 IsAvailableInChannel("", VersionInfo::CHANNEL_STABLE)); |
550 } | 545 } |
551 | 546 |
552 } // namespace | 547 } // namespace |
OLD | NEW |