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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
7 #include "chromeos/dbus/nfc_adapter_client.h" | 7 #include "chromeos/dbus/nfc_adapter_client.h" |
8 #include "chromeos/dbus/nfc_client_helpers.h" | 8 #include "chromeos/dbus/nfc_client_helpers.h" |
9 #include "chromeos/dbus/nfc_device_client.h" | 9 #include "chromeos/dbus/nfc_device_client.h" |
10 #include "chromeos/dbus/nfc_manager_client.h" | 10 #include "chromeos/dbus/nfc_manager_client.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 MOCK_METHOD2(DevicePropertyChanged, void(const dbus::ObjectPath&, | 65 MOCK_METHOD2(DevicePropertyChanged, void(const dbus::ObjectPath&, |
66 const std::string&)); | 66 const std::string&)); |
67 }; | 67 }; |
68 | 68 |
69 class MockNfcRecordObserver : public NfcRecordClient::Observer { | 69 class MockNfcRecordObserver : public NfcRecordClient::Observer { |
70 public: | 70 public: |
71 MOCK_METHOD1(RecordAdded, void(const dbus::ObjectPath&)); | 71 MOCK_METHOD1(RecordAdded, void(const dbus::ObjectPath&)); |
72 MOCK_METHOD1(RecordRemoved, void(const dbus::ObjectPath&)); | 72 MOCK_METHOD1(RecordRemoved, void(const dbus::ObjectPath&)); |
73 MOCK_METHOD2(RecordPropertyChanged, void(const dbus::ObjectPath&, | 73 MOCK_METHOD2(RecordPropertyChanged, void(const dbus::ObjectPath&, |
74 const std::string&)); | 74 const std::string&)); |
| 75 MOCK_METHOD1(RecordPropertiesReceived, void(const dbus::ObjectPath&)); |
75 }; | 76 }; |
76 | 77 |
77 class MockNfcTagObserver : public NfcTagClient::Observer { | 78 class MockNfcTagObserver : public NfcTagClient::Observer { |
78 public: | 79 public: |
79 MOCK_METHOD1(TagAdded, void(const dbus::ObjectPath&)); | 80 MOCK_METHOD1(TagAdded, void(const dbus::ObjectPath&)); |
80 MOCK_METHOD1(TagRemoved, void(const dbus::ObjectPath&)); | 81 MOCK_METHOD1(TagRemoved, void(const dbus::ObjectPath&)); |
81 MOCK_METHOD2(TagPropertyChanged, void(const dbus::ObjectPath&, | 82 MOCK_METHOD2(TagPropertyChanged, void(const dbus::ObjectPath&, |
82 const std::string&)); | 83 const std::string&)); |
83 }; | 84 }; |
84 | 85 |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 base::Bind(&NfcClientTest::ErrorCallback, base::Unretained(this))); | 501 base::Bind(&NfcClientTest::ErrorCallback, base::Unretained(this))); |
501 } | 502 } |
502 | 503 |
503 // Tests that when tags are added and removed through an adapter, all | 504 // Tests that when tags are added and removed through an adapter, all |
504 // observers are notified and the proxies are created and removed | 505 // observers are notified and the proxies are created and removed |
505 // accordingly. | 506 // accordingly. |
506 TEST_F(NfcClientTest, TagsAddedAndRemoved) { | 507 TEST_F(NfcClientTest, TagsAddedAndRemoved) { |
507 // Invoking methods on tags that haven't been added should fail. | 508 // Invoking methods on tags that haven't been added should fail. |
508 EXPECT_CALL(*this, | 509 EXPECT_CALL(*this, |
509 ErrorCallback(nfc_client_helpers::kUnknownObjectError, _)); | 510 ErrorCallback(nfc_client_helpers::kUnknownObjectError, _)); |
510 NfcRecordClient::Attributes write_data; | 511 base::DictionaryValue write_data; |
511 write_data[nfc_record::kTypeProperty] = nfc_record::kTypeText; | 512 write_data.SetString(nfc_record::kTypeProperty, nfc_record::kTypeText); |
512 tag_client_->Write(dbus::ObjectPath(kTestTagPath0), write_data, | 513 tag_client_->Write(dbus::ObjectPath(kTestTagPath0), write_data, |
513 base::Bind(&NfcClientTest::SuccessCallback, | 514 base::Bind(&NfcClientTest::SuccessCallback, |
514 base::Unretained(this)), | 515 base::Unretained(this)), |
515 base::Bind(&NfcClientTest::ErrorCallback, | 516 base::Bind(&NfcClientTest::ErrorCallback, |
516 base::Unretained(this))); | 517 base::Unretained(this))); |
517 Mock::VerifyAndClearExpectations(this); | 518 Mock::VerifyAndClearExpectations(this); |
518 | 519 |
519 // Add adapter 0. | 520 // Add adapter 0. |
520 ObjectPathVector adapter_paths; | 521 ObjectPathVector adapter_paths; |
521 adapter_paths.push_back(dbus::ObjectPath(kTestAdapterPath0)); | 522 adapter_paths.push_back(dbus::ObjectPath(kTestAdapterPath0)); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 base::Unretained(this))); | 630 base::Unretained(this))); |
630 } | 631 } |
631 | 632 |
632 // Tests that when devices are added and removed through an adapter, all | 633 // Tests that when devices are added and removed through an adapter, all |
633 // observers are notified and the proxies are created and removed | 634 // observers are notified and the proxies are created and removed |
634 // accordingly. | 635 // accordingly. |
635 TEST_F(NfcClientTest, DevicesAddedAndRemoved) { | 636 TEST_F(NfcClientTest, DevicesAddedAndRemoved) { |
636 // Invoking methods on devices that haven't been added should fail. | 637 // Invoking methods on devices that haven't been added should fail. |
637 EXPECT_CALL(*this, | 638 EXPECT_CALL(*this, |
638 ErrorCallback(nfc_client_helpers::kUnknownObjectError, _)); | 639 ErrorCallback(nfc_client_helpers::kUnknownObjectError, _)); |
639 NfcRecordClient::Attributes write_data; | 640 base::DictionaryValue write_data; |
640 write_data[nfc_record::kTypeProperty] = nfc_record::kTypeText; | 641 write_data.SetString(nfc_record::kTypeProperty, nfc_record::kTypeText); |
641 device_client_->Push(dbus::ObjectPath(kTestDevicePath0), write_data, | 642 device_client_->Push(dbus::ObjectPath(kTestDevicePath0), write_data, |
642 base::Bind(&NfcClientTest::SuccessCallback, | 643 base::Bind(&NfcClientTest::SuccessCallback, |
643 base::Unretained(this)), | 644 base::Unretained(this)), |
644 base::Bind(&NfcClientTest::ErrorCallback, | 645 base::Bind(&NfcClientTest::ErrorCallback, |
645 base::Unretained(this))); | 646 base::Unretained(this))); |
646 Mock::VerifyAndClearExpectations(this); | 647 Mock::VerifyAndClearExpectations(this); |
647 | 648 |
648 // Add adapter 0. | 649 // Add adapter 0. |
649 ObjectPathVector adapter_paths; | 650 ObjectPathVector adapter_paths; |
650 adapter_paths.push_back(dbus::ObjectPath(kTestAdapterPath0)); | 651 adapter_paths.push_back(dbus::ObjectPath(kTestAdapterPath0)); |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
872 EXPECT_CALL(mock_tag_observer_, | 873 EXPECT_CALL(mock_tag_observer_, |
873 TagRemoved(dbus::ObjectPath(kTestTagPath1))); | 874 TagRemoved(dbus::ObjectPath(kTestTagPath1))); |
874 EXPECT_CALL(mock_record_observer_, | 875 EXPECT_CALL(mock_record_observer_, |
875 RecordRemoved(dbus::ObjectPath(kTestRecordPath2))); | 876 RecordRemoved(dbus::ObjectPath(kTestRecordPath2))); |
876 EXPECT_CALL(mock_record_observer_, | 877 EXPECT_CALL(mock_record_observer_, |
877 RecordRemoved(dbus::ObjectPath(kTestRecordPath3))); | 878 RecordRemoved(dbus::ObjectPath(kTestRecordPath3))); |
878 SimulateAdaptersChanged(object_paths); | 879 SimulateAdaptersChanged(object_paths); |
879 } | 880 } |
880 | 881 |
881 } // namespace chromeos | 882 } // namespace chromeos |
OLD | NEW |