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

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

Issue 534133002: [WIP] bindings: Introduce PropertyBag (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 3 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 | « 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 9
10 namespace blink { 10 namespace blink {
11 11
12 DictionaryTest::DictionaryTest() 12 DictionaryTest::DictionaryTest()
13 { 13 {
14 } 14 }
15 15
16 DictionaryTest::~DictionaryTest() 16 DictionaryTest::~DictionaryTest()
17 { 17 {
18 } 18 }
19 19
20 void DictionaryTest::set(const InternalDictionary* testingDictionary) 20 void DictionaryTest::set(const InternalDictionary* testingDictionary)
21 { 21 {
22 reset(); 22 reset();
23 if (testingDictionary->hasLongMember()) 23 if (testingDictionary->hasLongMember())
24 m_longMember = testingDictionary->longMember(); 24 m_longMember = testingDictionary->longMember();
25 m_longMemberWithDefault = testingDictionary->longMemberWithDefault();
26 if (testingDictionary->hasLongOrNullMember())
27 m_longOrNullMember = testingDictionary->longOrNullMember();
28 // |longOrNullMemberWithDefault| has a default value but can be null, so
29 // we need to check availability.
30 if (testingDictionary->hasLongOrNullMemberWithDefault())
31 m_longOrNullMemberWithDefault = testingDictionary->longOrNullMemberWithD efault();
32 if (testingDictionary->hasBooleanMember())
33 m_booleanMember = testingDictionary->booleanMember();
34 if (testingDictionary->hasDoubleMember())
35 m_doubleMember = testingDictionary->doubleMember();
25 m_stringMember = testingDictionary->stringMember(); 36 m_stringMember = testingDictionary->stringMember();
26 if (testingDictionary->hasBooleanOrNullMember()) 37 m_stringMemberWithDefault = testingDictionary->stringMemberWithDefault();
27 m_booleanOrNullMember = testingDictionary->booleanOrNullMember();
28 if (testingDictionary->hasDoubleOrNullMember())
29 m_doubleOrNullMember = testingDictionary->doubleOrNullMember();
30 if (testingDictionary->hasStringSequenceMember()) 38 if (testingDictionary->hasStringSequenceMember())
31 m_stringSequenceMember = testingDictionary->stringSequenceMember(); 39 m_stringSequenceMember = testingDictionary->stringSequenceMember();
40 if (testingDictionary->hasStringSequenceOrNullMember())
41 m_stringSequenceOrNullMember = testingDictionary->stringSequenceOrNullMe mber();
42 if (testingDictionary->hasElementMember())
43 m_elementMember = testingDictionary->elementMember();
44 if (testingDictionary->hasElementOrNullMember())
45 m_elementOrNullMember = testingDictionary->elementOrNullMember();
32 } 46 }
33 47
34 InternalDictionary* DictionaryTest::get() 48 InternalDictionary* DictionaryTest::get()
35 { 49 {
36 InternalDictionary* result = InternalDictionary::create(); 50 InternalDictionary* result = InternalDictionary::create();
37 if (m_longMember) 51 if (m_longMember)
38 result->setLongMember(m_longMember.get()); 52 result->setLongMember(m_longMember.get());
53 result->setLongMemberWithDefault(m_longMemberWithDefault);
54 if (m_longOrNullMember)
55 result->setLongOrNullMember(m_longOrNullMember.get());
56 if (m_longOrNullMemberWithDefault)
57 result->setLongOrNullMemberWithDefault(m_longOrNullMemberWithDefault.get ());
58 if (m_booleanMember)
59 result->setBooleanMember(m_booleanMember.get());
60 if (m_doubleMember)
61 result->setDoubleMember(m_doubleMember.get());
39 result->setStringMember(m_stringMember); 62 result->setStringMember(m_stringMember);
40 if (m_booleanOrNullMember) 63 result->setStringMemberWithDefault(m_stringMemberWithDefault);
41 result->setBooleanOrNullMember(m_booleanOrNullMember.get());
42 if (m_doubleOrNullMember)
43 result->setDoubleOrNullMember(m_doubleOrNullMember.get());
44 if (m_stringSequenceMember) 64 if (m_stringSequenceMember)
45 result->setStringSequenceMember(m_stringSequenceMember.get()); 65 result->setStringSequenceMember(m_stringSequenceMember.get());
66 if (m_stringSequenceOrNullMember)
67 result->setStringSequenceOrNullMember(m_stringSequenceOrNullMember.get() );
68 if (m_elementMember)
69 result->setElementMember(m_elementMember);
70 if (m_elementOrNullMember)
71 result->setElementOrNullMember(m_elementOrNullMember);
46 return result; 72 return result;
47 } 73 }
48 74
49 void DictionaryTest::reset() 75 void DictionaryTest::reset()
50 { 76 {
51 m_longMember = Nullable<unsigned>(); 77 m_longMember = Nullable<int>();
78 m_longMemberWithDefault = -1; // This value should not be returned.
79 m_longOrNullMember = Nullable<int>();
80 m_longOrNullMemberWithDefault = Nullable<int>();
81 m_booleanMember = Nullable<bool>();
82 m_doubleMember = Nullable<double>();
52 m_stringMember = String(); 83 m_stringMember = String();
53 m_booleanOrNullMember = Nullable<bool>(); 84 m_stringMemberWithDefault = String("Should not be returned");
54 m_doubleOrNullMember = Nullable<double>();
55 m_stringSequenceMember = Nullable<Vector<String> >(); 85 m_stringSequenceMember = Nullable<Vector<String> >();
86 m_stringSequenceOrNullMember = Nullable<Vector<String> >();
87 m_elementMember = nullptr;
88 m_elementOrNullMember = nullptr;
56 } 89 }
57 90
58 void DictionaryTest::trace(Visitor*) 91 void DictionaryTest::trace(Visitor*)
59 { 92 {
60 } 93 }
61 94
62 } 95 }
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