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

Side by Side Diff: webrtc/test/common_unittest.cc

Issue 1586563003: Revert of Use an explicit identifier in Config (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 11 months 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 | « webrtc/modules/video_coding/codecs/vp8/temporal_layers.h ('k') | 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 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 #include "webrtc/common.h" 10 #include "webrtc/common.h"
11 11
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace webrtc { 14 namespace webrtc {
15 namespace { 15 namespace {
16 16
17 struct MyExperiment { 17 struct MyExperiment {
18 static const ConfigOptionID identifier = ConfigOptionID::kMyExperimentForTest;
19 static const int kDefaultFactor; 18 static const int kDefaultFactor;
20 static const int kDefaultOffset; 19 static const int kDefaultOffset;
21 20
22 MyExperiment() 21 MyExperiment()
23 : factor(kDefaultFactor), offset(kDefaultOffset) {} 22 : factor(kDefaultFactor), offset(kDefaultOffset) {}
24 23
25 MyExperiment(int factor, int offset) 24 MyExperiment(int factor, int offset)
26 : factor(factor), offset(offset) {} 25 : factor(factor), offset(offset) {}
27 26
28 int factor; 27 int factor;
(...skipping 21 matching lines...) Expand all
50 TEST(Config, SetNullSetsTheOptionBackToDefault) { 49 TEST(Config, SetNullSetsTheOptionBackToDefault) {
51 Config config; 50 Config config;
52 config.Set<MyExperiment>(new MyExperiment(5, 1)); 51 config.Set<MyExperiment>(new MyExperiment(5, 1));
53 config.Set<MyExperiment>(NULL); 52 config.Set<MyExperiment>(NULL);
54 const MyExperiment& my_exp = config.Get<MyExperiment>(); 53 const MyExperiment& my_exp = config.Get<MyExperiment>();
55 EXPECT_EQ(MyExperiment::kDefaultFactor, my_exp.factor); 54 EXPECT_EQ(MyExperiment::kDefaultFactor, my_exp.factor);
56 EXPECT_EQ(MyExperiment::kDefaultOffset, my_exp.offset); 55 EXPECT_EQ(MyExperiment::kDefaultOffset, my_exp.offset);
57 } 56 }
58 57
59 struct Algo1_CostFunction { 58 struct Algo1_CostFunction {
60 static const ConfigOptionID identifier =
61 ConfigOptionID::kAlgo1CostFunctionForTest;
62 Algo1_CostFunction() {} 59 Algo1_CostFunction() {}
63 60
64 virtual int cost(int x) const { 61 virtual int cost(int x) const {
65 return x; 62 return x;
66 } 63 }
67 64
68 virtual ~Algo1_CostFunction() {} 65 virtual ~Algo1_CostFunction() {}
69 }; 66 };
70 67
71 struct SqrCost : Algo1_CostFunction { 68 struct SqrCost : Algo1_CostFunction {
72 virtual int cost(int x) const { 69 virtual int cost(int x) const {
73 return x*x; 70 return x*x;
74 } 71 }
75 }; 72 };
76 73
77 TEST(Config, SupportsPolymorphism) { 74 TEST(Config, SupportsPolymorphism) {
78 Config config; 75 Config config;
79 config.Set<Algo1_CostFunction>(new SqrCost()); 76 config.Set<Algo1_CostFunction>(new SqrCost());
80 EXPECT_EQ(25, config.Get<Algo1_CostFunction>().cost(5)); 77 EXPECT_EQ(25, config.Get<Algo1_CostFunction>().cost(5));
81 } 78 }
82 } // namespace 79 } // namespace
83 } // namespace webrtc 80 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/codecs/vp8/temporal_layers.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698