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

Side by Side Diff: device/nfc/nfc_ndef_record_unittest.cc

Issue 1542163002: Switch to standard integer types in device/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: win Created 4 years, 12 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 | « device/nfc/nfc_ndef_record.cc ('k') | device/nfc/nfc_peer.h » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <stddef.h>
6 #include <stdint.h>
7
5 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
6 #include "base/values.h" 9 #include "base/values.h"
7 #include "device/nfc/nfc_ndef_record.h" 10 #include "device/nfc/nfc_ndef_record.h"
8 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
9 12
10 using base::DictionaryValue; 13 using base::DictionaryValue;
11 using base::ListValue; 14 using base::ListValue;
12 using base::StringValue; 15 using base::StringValue;
13 16
14 namespace device { 17 namespace device {
15 18
16 namespace { 19 namespace {
17 20
18 const char kTestAction[] = "test-action"; 21 const char kTestAction[] = "test-action";
19 const char kTestEncoding[] = "test-encoding"; 22 const char kTestEncoding[] = "test-encoding";
20 const char kTestLanguageCode[] = "test-language-code"; 23 const char kTestLanguageCode[] = "test-language-code";
21 const char kTestMimeType[] = "test-mime-type"; 24 const char kTestMimeType[] = "test-mime-type";
22 const uint32 kTestTargetSize = 0; 25 const uint32_t kTestTargetSize = 0;
23 const char kTestText[] = "test-text"; 26 const char kTestText[] = "test-text";
24 const char kTestURI[] = "test://uri"; 27 const char kTestURI[] = "test://uri";
25 28
26 } // namespace 29 } // namespace
27 30
28 TEST(NfcNdefRecordTest, PopulateTextRecord) { 31 TEST(NfcNdefRecordTest, PopulateTextRecord) {
29 DictionaryValue data; 32 DictionaryValue data;
30 scoped_ptr<NfcNdefRecord> record(new NfcNdefRecord()); 33 scoped_ptr<NfcNdefRecord> record(new NfcNdefRecord());
31 34
32 // Missing text field. Should fail. 35 // Missing text field. Should fail.
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 std::string string_value; 131 std::string string_value;
129 double double_value; 132 double double_value;
130 EXPECT_TRUE(record->data().GetString( 133 EXPECT_TRUE(record->data().GetString(
131 NfcNdefRecord::kFieldURI, &string_value)); 134 NfcNdefRecord::kFieldURI, &string_value));
132 EXPECT_EQ(kTestURI, string_value); 135 EXPECT_EQ(kTestURI, string_value);
133 EXPECT_TRUE(record->data().GetString( 136 EXPECT_TRUE(record->data().GetString(
134 NfcNdefRecord::kFieldMimeType, &string_value)); 137 NfcNdefRecord::kFieldMimeType, &string_value));
135 EXPECT_EQ(kTestMimeType, string_value); 138 EXPECT_EQ(kTestMimeType, string_value);
136 EXPECT_TRUE(record->data().GetDouble( 139 EXPECT_TRUE(record->data().GetDouble(
137 NfcNdefRecord::kFieldTargetSize, &double_value)); 140 NfcNdefRecord::kFieldTargetSize, &double_value));
138 EXPECT_EQ(kTestTargetSize, static_cast<uint32>(double_value)); 141 EXPECT_EQ(kTestTargetSize, static_cast<uint32_t>(double_value));
139 } 142 }
140 143
141 TEST(NfcNdefRecordTest, PopulateSmartPoster) { 144 TEST(NfcNdefRecordTest, PopulateSmartPoster) {
142 DictionaryValue data; 145 DictionaryValue data;
143 scoped_ptr<NfcNdefRecord> record(new NfcNdefRecord()); 146 scoped_ptr<NfcNdefRecord> record(new NfcNdefRecord());
144 147
145 // Missing URI field. Should fail. 148 // Missing URI field. Should fail.
146 EXPECT_FALSE(record->Populate(NfcNdefRecord::kTypeSmartPoster, &data)); 149 EXPECT_FALSE(record->Populate(NfcNdefRecord::kTypeSmartPoster, &data));
147 EXPECT_FALSE(record->IsPopulated()); 150 EXPECT_FALSE(record->IsPopulated());
148 151
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 const ListValue* const_list_value; 221 const ListValue* const_list_value;
219 const DictionaryValue* const_dictionary_value; 222 const DictionaryValue* const_dictionary_value;
220 EXPECT_TRUE(record->data().GetString( 223 EXPECT_TRUE(record->data().GetString(
221 NfcNdefRecord::kFieldURI, &string_value)); 224 NfcNdefRecord::kFieldURI, &string_value));
222 EXPECT_EQ(kTestURI, string_value); 225 EXPECT_EQ(kTestURI, string_value);
223 EXPECT_TRUE(record->data().GetString( 226 EXPECT_TRUE(record->data().GetString(
224 NfcNdefRecord::kFieldMimeType, &string_value)); 227 NfcNdefRecord::kFieldMimeType, &string_value));
225 EXPECT_EQ(kTestMimeType, string_value); 228 EXPECT_EQ(kTestMimeType, string_value);
226 EXPECT_TRUE(record->data().GetDouble( 229 EXPECT_TRUE(record->data().GetDouble(
227 NfcNdefRecord::kFieldTargetSize, &double_value)); 230 NfcNdefRecord::kFieldTargetSize, &double_value));
228 EXPECT_EQ(kTestTargetSize, static_cast<uint32>(double_value)); 231 EXPECT_EQ(kTestTargetSize, static_cast<uint32_t>(double_value));
229 EXPECT_TRUE(record->data().GetString( 232 EXPECT_TRUE(record->data().GetString(
230 NfcNdefRecord::kFieldAction, &string_value)); 233 NfcNdefRecord::kFieldAction, &string_value));
231 EXPECT_EQ(kTestAction, string_value); 234 EXPECT_EQ(kTestAction, string_value);
232 EXPECT_TRUE(record->data().GetList( 235 EXPECT_TRUE(record->data().GetList(
233 NfcNdefRecord::kFieldTitles, &const_list_value)); 236 NfcNdefRecord::kFieldTitles, &const_list_value));
234 EXPECT_EQ(static_cast<size_t>(1), const_list_value->GetSize()); 237 EXPECT_EQ(static_cast<size_t>(1), const_list_value->GetSize());
235 EXPECT_TRUE(const_list_value->GetDictionary(0, &const_dictionary_value)); 238 EXPECT_TRUE(const_list_value->GetDictionary(0, &const_dictionary_value));
236 EXPECT_TRUE(const_dictionary_value->GetString( 239 EXPECT_TRUE(const_dictionary_value->GetString(
237 NfcNdefRecord::kFieldText, &string_value)); 240 NfcNdefRecord::kFieldText, &string_value));
238 EXPECT_EQ(kTestText, string_value); 241 EXPECT_EQ(kTestText, string_value);
239 EXPECT_TRUE(const_dictionary_value->GetString( 242 EXPECT_TRUE(const_dictionary_value->GetString(
240 NfcNdefRecord::kFieldLanguageCode, &string_value)); 243 NfcNdefRecord::kFieldLanguageCode, &string_value));
241 EXPECT_EQ(kTestLanguageCode, string_value); 244 EXPECT_EQ(kTestLanguageCode, string_value);
242 EXPECT_TRUE(const_dictionary_value->GetString( 245 EXPECT_TRUE(const_dictionary_value->GetString(
243 NfcNdefRecord::kFieldEncoding, &string_value)); 246 NfcNdefRecord::kFieldEncoding, &string_value));
244 EXPECT_EQ(kTestEncoding, string_value); 247 EXPECT_EQ(kTestEncoding, string_value);
245 } 248 }
246 249
247 } // namespace device 250 } // namespace device
OLDNEW
« no previous file with comments | « device/nfc/nfc_ndef_record.cc ('k') | device/nfc/nfc_peer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698