Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: tools/json_schema_compiler/test/features_generation_unittest.cc

Issue 2542163002: Fix invalid casts from ComplexFeature to SimpleFeature. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/api_feature.h" 5 #include "extensions/common/features/api_feature.h"
6 #include "extensions/common/features/complex_feature.h" 6 #include "extensions/common/features/complex_feature.h"
7 #include "extensions/common/features/feature.h" 7 #include "extensions/common/features/feature.h"
8 #include "extensions/common/features/simple_feature.h" 8 #include "extensions/common/features/simple_feature.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "tools/json_schema_compiler/test/features_compiler_test.h" 10 #include "tools/json_schema_compiler/test/features_compiler_test.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 EXPECT_EQ(*channel, feature->channel()) << name; 89 EXPECT_EQ(*channel, feature->channel()) << name;
90 EXPECT_EQ(internal, feature->IsInternal()) << name; 90 EXPECT_EQ(internal, feature->IsInternal()) << name;
91 EXPECT_EQ(alias, feature->alias()) << name; 91 EXPECT_EQ(alias, feature->alias()) << name;
92 EXPECT_EQ(source, feature->source()) << name; 92 EXPECT_EQ(source, feature->source()) << name;
93 } 93 }
94 94
95 TEST(FeaturesGenerationTest, FeaturesTest) { 95 TEST(FeaturesGenerationTest, FeaturesTest) {
96 CompilerTestFeatureProvider provider; 96 CompilerTestFeatureProvider provider;
97 97
98 auto GetAPIFeature = [&provider](const std::string& name) { 98 auto GetAPIFeature = [&provider](const std::string& name) {
99 fprintf(stderr, "GetAPIFeature(\"%s\")\n", name.c_str());
tbarzic 2016/12/01 19:02:29 remove :)
krasin1 2016/12/01 20:41:12 Done.
99 Feature* feature = provider.GetFeature(name); 100 Feature* feature = provider.GetFeature(name);
100 // Shame we can't test this more safely, but if our feature is declared as 101 // Shame we can't test this more safely, but if our feature is declared as
101 // the wrong class, things should blow up in a spectacular fashion. 102 // the wrong class, things should blow up in a spectacular fashion.
102 return static_cast<APIFeature*>(feature); 103 return static_cast<APIFeature*>(feature);
103 }; 104 };
104 105
105 // Check some simple features for accuracy. 106 // Check some simple features for accuracy.
106 { 107 {
107 APIFeature* feature = GetAPIFeature("alpha"); 108 APIFeature* feature = GetAPIFeature("alpha");
108 FeatureComparator comparator("alpha"); 109 FeatureComparator comparator("alpha");
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 { 281 {
281 APIFeature* feature = GetAPIFeature("alias_source"); 282 APIFeature* feature = GetAPIFeature("alias_source");
282 FeatureComparator comparator("alias_source"); 283 FeatureComparator comparator("alias_source");
283 comparator.contexts = {Feature::BLESSED_EXTENSION_CONTEXT}; 284 comparator.contexts = {Feature::BLESSED_EXTENSION_CONTEXT};
284 comparator.channel.reset( 285 comparator.channel.reset(
285 new version_info::Channel(version_info::Channel::STABLE)); 286 new version_info::Channel(version_info::Channel::STABLE));
286 comparator.alias = "alias"; 287 comparator.alias = "alias";
287 comparator.CompareFeature(feature); 288 comparator.CompareFeature(feature);
288 } 289 }
289 { 290 {
290 Feature* feature = GetAPIFeature("complex_alias"); 291 Feature* feature =
292 static_cast<ComplexFeature*>(provider.GetFeature("complex_alias"));
tbarzic 2016/12/01 19:02:29 I don't think cast is needed if provider.GetFeatur
krasin1 2016/12/01 20:41:13 Done.
291 ASSERT_EQ("", feature->alias()); 293 ASSERT_EQ("", feature->alias());
292 ASSERT_EQ("complex_alias_source", feature->source()); 294 ASSERT_EQ("complex_alias_source", feature->source());
293 } 295 }
294 { 296 {
295 Feature* feature = GetAPIFeature("complex_alias_source"); 297 Feature* feature = static_cast<ComplexFeature*>(
298 provider.GetFeature("complex_alias_source"));
296 ASSERT_EQ("complex_alias", feature->alias()); 299 ASSERT_EQ("complex_alias", feature->alias());
297 ASSERT_EQ("", feature->source()); 300 ASSERT_EQ("", feature->source());
298 } 301 }
299 { 302 {
300 Feature* feature = GetAPIFeature("parent_source"); 303 Feature* feature = GetAPIFeature("parent_source");
301 ASSERT_EQ("parent_source_alias", feature->alias()); 304 ASSERT_EQ("parent_source_alias", feature->alias());
302 ASSERT_EQ("", feature->source()); 305 ASSERT_EQ("", feature->source());
303 } 306 }
304 { 307 {
305 Feature* feature = GetAPIFeature("parent_source.child"); 308 Feature* feature = GetAPIFeature("parent_source.child");
(...skipping 11 matching lines...) Expand all
317 ASSERT_EQ("", feature->source()); 320 ASSERT_EQ("", feature->source());
318 } 321 }
319 { 322 {
320 Feature* feature = GetAPIFeature("alias_parent.child"); 323 Feature* feature = GetAPIFeature("alias_parent.child");
321 ASSERT_EQ("", feature->alias()); 324 ASSERT_EQ("", feature->alias());
322 ASSERT_EQ("child_source", feature->source()); 325 ASSERT_EQ("child_source", feature->source());
323 } 326 }
324 } 327 }
325 328
326 } // namespace extensions 329 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698