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

Side by Side Diff: Source/core/testing/DictionaryTest.cpp

Issue 724733002: Support for [Clamp] and [EnforceRange] to IDL dictionary. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 1 month 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 | « Source/core/testing/DictionaryTest.h ('k') | Source/core/testing/InternalDictionary.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "config.h" 5 #include "config.h"
6 #include "DictionaryTest.h" 6 #include "DictionaryTest.h"
7 7
8 #include "core/testing/InternalDictionary.h" 8 #include "core/testing/InternalDictionary.h"
9 #include "core/testing/InternalDictionaryDerived.h" 9 #include "core/testing/InternalDictionaryDerived.h"
10 10
11 namespace blink { 11 namespace blink {
12 12
13 DictionaryTest::DictionaryTest() 13 DictionaryTest::DictionaryTest()
14 { 14 {
15 } 15 }
16 16
17 DictionaryTest::~DictionaryTest() 17 DictionaryTest::~DictionaryTest()
18 { 18 {
19 } 19 }
20 20
21 void DictionaryTest::set(const InternalDictionary& testingDictionary) 21 void DictionaryTest::set(const InternalDictionary& testingDictionary)
22 { 22 {
23 reset(); 23 reset();
24 if (testingDictionary.hasLongMember()) 24 if (testingDictionary.hasLongMember())
25 m_longMember = testingDictionary.longMember(); 25 m_longMember = testingDictionary.longMember();
26 if (testingDictionary.hasLongMemberWithClamp())
27 m_longMemberWithClamp = testingDictionary.longMemberWithClamp();
28 if (testingDictionary.hasLongMemberWithEnforceRange())
29 m_longMemberWithEnforceRange = testingDictionary.longMemberWithEnforceRa nge();
26 m_longMemberWithDefault = testingDictionary.longMemberWithDefault(); 30 m_longMemberWithDefault = testingDictionary.longMemberWithDefault();
27 if (testingDictionary.hasLongOrNullMember()) 31 if (testingDictionary.hasLongOrNullMember())
28 m_longOrNullMember = testingDictionary.longOrNullMember(); 32 m_longOrNullMember = testingDictionary.longOrNullMember();
29 // |longOrNullMemberWithDefault| has a default value but can be null, so 33 // |longOrNullMemberWithDefault| has a default value but can be null, so
30 // we need to check availability. 34 // we need to check availability.
31 if (testingDictionary.hasLongOrNullMemberWithDefault()) 35 if (testingDictionary.hasLongOrNullMemberWithDefault())
32 m_longOrNullMemberWithDefault = testingDictionary.longOrNullMemberWithDe fault(); 36 m_longOrNullMemberWithDefault = testingDictionary.longOrNullMemberWithDe fault();
33 if (testingDictionary.hasBooleanMember()) 37 if (testingDictionary.hasBooleanMember())
34 m_booleanMember = testingDictionary.booleanMember(); 38 m_booleanMember = testingDictionary.booleanMember();
35 if (testingDictionary.hasDoubleMember()) 39 if (testingDictionary.hasDoubleMember())
(...skipping 12 matching lines...) Expand all
48 if (testingDictionary.hasElementOrNullMember()) 52 if (testingDictionary.hasElementOrNullMember())
49 m_elementOrNullMember = testingDictionary.elementOrNullMember(); 53 m_elementOrNullMember = testingDictionary.elementOrNullMember();
50 m_objectMember = testingDictionary.objectMember(); 54 m_objectMember = testingDictionary.objectMember();
51 m_objectOrNullMemberWithDefault = testingDictionary.objectOrNullMemberWithDe fault(); 55 m_objectOrNullMemberWithDefault = testingDictionary.objectOrNullMemberWithDe fault();
52 } 56 }
53 57
54 void DictionaryTest::get(InternalDictionary& result) 58 void DictionaryTest::get(InternalDictionary& result)
55 { 59 {
56 if (m_longMember) 60 if (m_longMember)
57 result.setLongMember(m_longMember.get()); 61 result.setLongMember(m_longMember.get());
62 if (m_longMemberWithClamp)
63 result.setLongMemberWithClamp(m_longMemberWithClamp.get());
64 if (m_longMemberWithEnforceRange)
65 result.setLongMemberWithEnforceRange(m_longMemberWithEnforceRange.get()) ;
58 result.setLongMemberWithDefault(m_longMemberWithDefault); 66 result.setLongMemberWithDefault(m_longMemberWithDefault);
59 if (m_longOrNullMember) 67 if (m_longOrNullMember)
60 result.setLongOrNullMember(m_longOrNullMember.get()); 68 result.setLongOrNullMember(m_longOrNullMember.get());
61 if (m_longOrNullMemberWithDefault) 69 if (m_longOrNullMemberWithDefault)
62 result.setLongOrNullMemberWithDefault(m_longOrNullMemberWithDefault.get( )); 70 result.setLongOrNullMemberWithDefault(m_longOrNullMemberWithDefault.get( ));
63 if (m_booleanMember) 71 if (m_booleanMember)
64 result.setBooleanMember(m_booleanMember.get()); 72 result.setBooleanMember(m_booleanMember.get());
65 if (m_doubleMember) 73 if (m_doubleMember)
66 result.setDoubleMember(m_doubleMember.get()); 74 result.setDoubleMember(m_doubleMember.get());
67 result.setStringMember(m_stringMember); 75 result.setStringMember(m_stringMember);
(...skipping 24 matching lines...) Expand all
92 void DictionaryTest::getDerived(InternalDictionaryDerived& result) 100 void DictionaryTest::getDerived(InternalDictionaryDerived& result)
93 { 101 {
94 get(result); 102 get(result);
95 result.setDerivedStringMember(m_derivedStringMember); 103 result.setDerivedStringMember(m_derivedStringMember);
96 result.setDerivedStringMemberWithDefault(m_derivedStringMemberWithDefault); 104 result.setDerivedStringMemberWithDefault(m_derivedStringMemberWithDefault);
97 } 105 }
98 106
99 void DictionaryTest::reset() 107 void DictionaryTest::reset()
100 { 108 {
101 m_longMember = Nullable<int>(); 109 m_longMember = Nullable<int>();
110 m_longMemberWithClamp = Nullable<int>();
111 m_longMemberWithEnforceRange = Nullable<int>();
102 m_longMemberWithDefault = -1; // This value should not be returned. 112 m_longMemberWithDefault = -1; // This value should not be returned.
103 m_longOrNullMember = Nullable<int>(); 113 m_longOrNullMember = Nullable<int>();
104 m_longOrNullMemberWithDefault = Nullable<int>(); 114 m_longOrNullMemberWithDefault = Nullable<int>();
105 m_booleanMember = Nullable<bool>(); 115 m_booleanMember = Nullable<bool>();
106 m_doubleMember = Nullable<double>(); 116 m_doubleMember = Nullable<double>();
107 m_stringMember = String(); 117 m_stringMember = String();
108 m_stringMemberWithDefault = String("Should not be returned"); 118 m_stringMemberWithDefault = String("Should not be returned");
109 m_stringSequenceMember = Nullable<Vector<String> >(); 119 m_stringSequenceMember = Nullable<Vector<String> >();
110 m_stringSequenceOrNullMember = Nullable<Vector<String> >(); 120 m_stringSequenceOrNullMember = Nullable<Vector<String> >();
111 m_enumMember = String(); 121 m_enumMember = String();
112 m_enumMemberWithDefault = String(); 122 m_enumMemberWithDefault = String();
113 m_enumOrNullMember = String(); 123 m_enumOrNullMember = String();
114 m_elementMember = nullptr; 124 m_elementMember = nullptr;
115 m_elementOrNullMember = nullptr; 125 m_elementOrNullMember = nullptr;
116 m_objectMember = ScriptValue(); 126 m_objectMember = ScriptValue();
117 m_objectOrNullMemberWithDefault = ScriptValue(); 127 m_objectOrNullMemberWithDefault = ScriptValue();
118 m_derivedStringMember = String(); 128 m_derivedStringMember = String();
119 m_derivedStringMemberWithDefault = String(); 129 m_derivedStringMemberWithDefault = String();
120 } 130 }
121 131
122 void DictionaryTest::trace(Visitor* visitor) 132 void DictionaryTest::trace(Visitor* visitor)
123 { 133 {
124 visitor->trace(m_elementMember); 134 visitor->trace(m_elementMember);
125 visitor->trace(m_elementOrNullMember); 135 visitor->trace(m_elementOrNullMember);
126 } 136 }
127 137
128 } 138 }
OLDNEW
« no previous file with comments | « Source/core/testing/DictionaryTest.h ('k') | Source/core/testing/InternalDictionary.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698