OLD | NEW |
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> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
| 8 #include <memory> |
| 9 |
8 #include "base/callback.h" | 10 #include "base/callback.h" |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
11 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
12 #include "base/values.h" | 13 #include "base/values.h" |
13 #include "chromeos/dbus/dbus_thread_manager.h" | 14 #include "chromeos/dbus/dbus_thread_manager.h" |
14 #include "chromeos/dbus/fake_nfc_adapter_client.h" | 15 #include "chromeos/dbus/fake_nfc_adapter_client.h" |
15 #include "chromeos/dbus/fake_nfc_device_client.h" | 16 #include "chromeos/dbus/fake_nfc_device_client.h" |
16 #include "chromeos/dbus/fake_nfc_record_client.h" | 17 #include "chromeos/dbus/fake_nfc_record_client.h" |
17 #include "chromeos/dbus/fake_nfc_tag_client.h" | 18 #include "chromeos/dbus/fake_nfc_tag_client.h" |
18 #include "device/nfc/nfc_adapter_chromeos.h" | 19 #include "device/nfc/nfc_adapter_chromeos.h" |
19 #include "device/nfc/nfc_ndef_record.h" | 20 #include "device/nfc/nfc_ndef_record.h" |
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 const char kLanguageCode[] = "en"; | 666 const char kLanguageCode[] = "en"; |
666 const char kMimeType[] = "mime-type"; | 667 const char kMimeType[] = "mime-type"; |
667 const double kSize = 5; | 668 const double kSize = 5; |
668 | 669 |
669 // Text record. | 670 // Text record. |
670 base::DictionaryValue data; | 671 base::DictionaryValue data; |
671 data.SetString(NfcNdefRecord::kFieldText, kText); | 672 data.SetString(NfcNdefRecord::kFieldText, kText); |
672 data.SetString(NfcNdefRecord::kFieldLanguageCode, kLanguageCode); | 673 data.SetString(NfcNdefRecord::kFieldLanguageCode, kLanguageCode); |
673 data.SetString(NfcNdefRecord::kFieldEncoding, kEncoding); | 674 data.SetString(NfcNdefRecord::kFieldEncoding, kEncoding); |
674 | 675 |
675 scoped_ptr<NfcNdefRecord> record(new NfcNdefRecord()); | 676 std::unique_ptr<NfcNdefRecord> record(new NfcNdefRecord()); |
676 ASSERT_TRUE(record->Populate(NfcNdefRecord::kTypeText, &data)); | 677 ASSERT_TRUE(record->Populate(NfcNdefRecord::kTypeText, &data)); |
677 | 678 |
678 base::DictionaryValue result; | 679 base::DictionaryValue result; |
679 EXPECT_TRUE(nfc_ndef_record_utils::NfcNdefRecordToDBusAttributes( | 680 EXPECT_TRUE(nfc_ndef_record_utils::NfcNdefRecordToDBusAttributes( |
680 record.get(), &result)); | 681 record.get(), &result)); |
681 | 682 |
682 std::string string_value; | 683 std::string string_value; |
683 EXPECT_TRUE(result.GetString( | 684 EXPECT_TRUE(result.GetString( |
684 nfc_record::kTypeProperty, &string_value)); | 685 nfc_record::kTypeProperty, &string_value)); |
685 EXPECT_EQ(nfc_record::kTypeText, string_value); | 686 EXPECT_EQ(nfc_record::kTypeText, string_value); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 | 764 |
764 FakeNfcRecordClient::Properties record_properties( | 765 FakeNfcRecordClient::Properties record_properties( |
765 base::Bind(&OnPropertyChangedCallback)); | 766 base::Bind(&OnPropertyChangedCallback)); |
766 | 767 |
767 // Text record. | 768 // Text record. |
768 record_properties.type.ReplaceValue(nfc_record::kTypeText); | 769 record_properties.type.ReplaceValue(nfc_record::kTypeText); |
769 record_properties.representation.ReplaceValue(kText); | 770 record_properties.representation.ReplaceValue(kText); |
770 record_properties.language.ReplaceValue(kLanguageCode); | 771 record_properties.language.ReplaceValue(kLanguageCode); |
771 record_properties.encoding.ReplaceValue(kEncoding); | 772 record_properties.encoding.ReplaceValue(kEncoding); |
772 | 773 |
773 scoped_ptr<NfcNdefRecord> record(new NfcNdefRecord()); | 774 std::unique_ptr<NfcNdefRecord> record(new NfcNdefRecord()); |
774 EXPECT_TRUE(nfc_ndef_record_utils::RecordPropertiesToNfcNdefRecord( | 775 EXPECT_TRUE(nfc_ndef_record_utils::RecordPropertiesToNfcNdefRecord( |
775 &record_properties, record.get())); | 776 &record_properties, record.get())); |
776 EXPECT_TRUE(record->IsPopulated()); | 777 EXPECT_TRUE(record->IsPopulated()); |
777 | 778 |
778 std::string string_value; | 779 std::string string_value; |
779 EXPECT_EQ(NfcNdefRecord::kTypeText, record->type()); | 780 EXPECT_EQ(NfcNdefRecord::kTypeText, record->type()); |
780 EXPECT_TRUE(record->data().GetString( | 781 EXPECT_TRUE(record->data().GetString( |
781 NfcNdefRecord::kFieldText, &string_value)); | 782 NfcNdefRecord::kFieldText, &string_value)); |
782 EXPECT_EQ(kText, string_value); | 783 EXPECT_EQ(kText, string_value); |
783 EXPECT_TRUE(record->data().GetString( | 784 EXPECT_TRUE(record->data().GetString( |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 EXPECT_TRUE(title->GetString(NfcNdefRecord::kFieldText, &string_value)); | 853 EXPECT_TRUE(title->GetString(NfcNdefRecord::kFieldText, &string_value)); |
853 EXPECT_EQ(kText, string_value); | 854 EXPECT_EQ(kText, string_value); |
854 EXPECT_TRUE(title->GetString( | 855 EXPECT_TRUE(title->GetString( |
855 NfcNdefRecord::kFieldLanguageCode, &string_value)); | 856 NfcNdefRecord::kFieldLanguageCode, &string_value)); |
856 EXPECT_EQ(kLanguageCode, string_value); | 857 EXPECT_EQ(kLanguageCode, string_value); |
857 EXPECT_TRUE(title->GetString(NfcNdefRecord::kFieldEncoding, &string_value)); | 858 EXPECT_TRUE(title->GetString(NfcNdefRecord::kFieldEncoding, &string_value)); |
858 EXPECT_EQ(kEncoding, string_value); | 859 EXPECT_EQ(kEncoding, string_value); |
859 } | 860 } |
860 | 861 |
861 } // namespace chromeos | 862 } // namespace chromeos |
OLD | NEW |