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

Side by Side Diff: chromeos/dbus/nfc_client_unittest.cc

Issue 99903003: nfc: Various fixes to the NFC D-Bus client in chromeos/dbus. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | Annotate | Revision Log
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 "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
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 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 base::Bind(&NfcClientTest::ErrorCallback, base::Unretained(this))); 509 base::Bind(&NfcClientTest::ErrorCallback, base::Unretained(this)));
509 } 510 }
510 511
511 // Tests that when tags are added and removed through an adapter, all 512 // Tests that when tags are added and removed through an adapter, all
512 // observers are notified and the proxies are created and removed 513 // observers are notified and the proxies are created and removed
513 // accordingly. 514 // accordingly.
514 TEST_F(NfcClientTest, TagsAddedAndRemoved) { 515 TEST_F(NfcClientTest, TagsAddedAndRemoved) {
515 // Invoking methods on tags that haven't been added should fail. 516 // Invoking methods on tags that haven't been added should fail.
516 EXPECT_CALL(*this, 517 EXPECT_CALL(*this,
517 ErrorCallback(nfc_client_helpers::kUnknownObjectError, _)); 518 ErrorCallback(nfc_client_helpers::kUnknownObjectError, _));
518 NfcRecordClient::Attributes write_data; 519 base::DictionaryValue write_data;
519 write_data[nfc_record::kTypeProperty] = nfc_record::kTypeText; 520 write_data.SetString(nfc_record::kTypeProperty, nfc_record::kTypeText);
520 tag_client_->Write(dbus::ObjectPath(kTestTagPath0), write_data, 521 tag_client_->Write(dbus::ObjectPath(kTestTagPath0), write_data,
521 base::Bind(&NfcClientTest::SuccessCallback, 522 base::Bind(&NfcClientTest::SuccessCallback,
522 base::Unretained(this)), 523 base::Unretained(this)),
523 base::Bind(&NfcClientTest::ErrorCallback, 524 base::Bind(&NfcClientTest::ErrorCallback,
524 base::Unretained(this))); 525 base::Unretained(this)));
525 Mock::VerifyAndClearExpectations(this); 526 Mock::VerifyAndClearExpectations(this);
526 527
527 // Add adapter 0. 528 // Add adapter 0.
528 ObjectPathVector adapter_paths; 529 ObjectPathVector adapter_paths;
529 adapter_paths.push_back(dbus::ObjectPath(kTestAdapterPath0)); 530 adapter_paths.push_back(dbus::ObjectPath(kTestAdapterPath0));
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 base::Unretained(this))); 638 base::Unretained(this)));
638 } 639 }
639 640
640 // Tests that when devices are added and removed through an adapter, all 641 // Tests that when devices are added and removed through an adapter, all
641 // observers are notified and the proxies are created and removed 642 // observers are notified and the proxies are created and removed
642 // accordingly. 643 // accordingly.
643 TEST_F(NfcClientTest, DevicesAddedAndRemoved) { 644 TEST_F(NfcClientTest, DevicesAddedAndRemoved) {
644 // Invoking methods on devices that haven't been added should fail. 645 // Invoking methods on devices that haven't been added should fail.
645 EXPECT_CALL(*this, 646 EXPECT_CALL(*this,
646 ErrorCallback(nfc_client_helpers::kUnknownObjectError, _)); 647 ErrorCallback(nfc_client_helpers::kUnknownObjectError, _));
647 NfcRecordClient::Attributes write_data; 648 base::DictionaryValue write_data;
648 write_data[nfc_record::kTypeProperty] = nfc_record::kTypeText; 649 write_data.SetString(nfc_record::kTypeProperty, nfc_record::kTypeText);
649 device_client_->Push(dbus::ObjectPath(kTestDevicePath0), write_data, 650 device_client_->Push(dbus::ObjectPath(kTestDevicePath0), write_data,
650 base::Bind(&NfcClientTest::SuccessCallback, 651 base::Bind(&NfcClientTest::SuccessCallback,
651 base::Unretained(this)), 652 base::Unretained(this)),
652 base::Bind(&NfcClientTest::ErrorCallback, 653 base::Bind(&NfcClientTest::ErrorCallback,
653 base::Unretained(this))); 654 base::Unretained(this)));
654 Mock::VerifyAndClearExpectations(this); 655 Mock::VerifyAndClearExpectations(this);
655 656
656 // Add adapter 0. 657 // Add adapter 0.
657 ObjectPathVector adapter_paths; 658 ObjectPathVector adapter_paths;
658 adapter_paths.push_back(dbus::ObjectPath(kTestAdapterPath0)); 659 adapter_paths.push_back(dbus::ObjectPath(kTestAdapterPath0));
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 EXPECT_CALL(mock_tag_observer_, 881 EXPECT_CALL(mock_tag_observer_,
881 TagRemoved(dbus::ObjectPath(kTestTagPath1))); 882 TagRemoved(dbus::ObjectPath(kTestTagPath1)));
882 EXPECT_CALL(mock_record_observer_, 883 EXPECT_CALL(mock_record_observer_,
883 RecordRemoved(dbus::ObjectPath(kTestRecordPath2))); 884 RecordRemoved(dbus::ObjectPath(kTestRecordPath2)));
884 EXPECT_CALL(mock_record_observer_, 885 EXPECT_CALL(mock_record_observer_,
885 RecordRemoved(dbus::ObjectPath(kTestRecordPath3))); 886 RecordRemoved(dbus::ObjectPath(kTestRecordPath3)));
886 SimulateAdaptersChanged(object_paths); 887 SimulateAdaptersChanged(object_paths);
887 } 888 }
888 889
889 } // namespace chromeos 890 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698