| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "mojo/public/cpp/application/application_impl.h" | 7 #include "mojo/public/cpp/application/application_impl.h" |
| 8 #include "mojo/public/cpp/application/application_test_base.h" | 8 #include "mojo/public/cpp/application/application_test_base.h" |
| 9 #include "mojo/public/cpp/bindings/callback.h" | 9 #include "mojo/public/cpp/bindings/callback.h" |
| 10 #include "mojo/public/cpp/environment/logging.h" | 10 #include "mojo/public/cpp/environment/logging.h" |
| 11 #include "mojo/public/cpp/system/macros.h" | 11 #include "mojo/public/cpp/system/macros.h" |
| 12 #include "mojo/services/nfc/interfaces/nfc.mojom.h" | 12 #include "mojo/services/nfc/interfaces/nfc.mojom.h" |
| 13 | 13 |
| 14 namespace mojo { | 14 namespace mojo { |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 // Tests the NFC mojo service on android. | 17 // Tests the NFC mojo service on android. |
| 18 class NfcApplicationTest : public test::ApplicationTestBase { | 18 class NfcApplicationTest : public test::ApplicationTestBase { |
| 19 public: | 19 public: |
| 20 NfcApplicationTest() : ApplicationTestBase() {} | 20 NfcApplicationTest() : ApplicationTestBase() {} |
| 21 ~NfcApplicationTest() override {} | 21 ~NfcApplicationTest() override {} |
| 22 | 22 |
| 23 void TransmitOnNextConnectionResult(bool success) {} | 23 void TransmitOnNextConnectionResult(bool success) {} |
| 24 | 24 |
| 25 protected: | 25 protected: |
| 26 // ApplicationTestBase: | 26 // ApplicationTestBase: |
| 27 void SetUp() override { | 27 void SetUp() override { |
| 28 ApplicationTestBase::SetUp(); | 28 ApplicationTestBase::SetUp(); |
| 29 application_impl()->ConnectToService("mojo:nfc", &nfc_); | 29 application_impl()->ConnectToServiceDeprecated("mojo:nfc", &nfc_); |
| 30 } | 30 } |
| 31 | 31 |
| 32 nfc::NfcPtr nfc_; | 32 nfc::NfcPtr nfc_; |
| 33 nfc::NfcTransmissionPtr nfc_transmission_; | 33 nfc::NfcTransmissionPtr nfc_transmission_; |
| 34 | 34 |
| 35 private: | 35 private: |
| 36 MOJO_DISALLOW_COPY_AND_ASSIGN(NfcApplicationTest); | 36 MOJO_DISALLOW_COPY_AND_ASSIGN(NfcApplicationTest); |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 TEST_F(NfcApplicationTest, TransmitAndCancelNfc) { | 39 TEST_F(NfcApplicationTest, TransmitAndCancelNfc) { |
| 40 nfc::NfcDataPtr nfc_data = nfc::NfcData::New(); | 40 nfc::NfcDataPtr nfc_data = nfc::NfcData::New(); |
| 41 nfc_->TransmitOnNextConnection( | 41 nfc_->TransmitOnNextConnection( |
| 42 nfc_data.Pass(), GetProxy(&nfc_transmission_), | 42 nfc_data.Pass(), GetProxy(&nfc_transmission_), |
| 43 base::Bind(&NfcApplicationTest::TransmitOnNextConnectionResult, | 43 base::Bind(&NfcApplicationTest::TransmitOnNextConnectionResult, |
| 44 base::Unretained(this))); | 44 base::Unretained(this))); |
| 45 nfc_transmission_->Cancel(); | 45 nfc_transmission_->Cancel(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 TEST_F(NfcApplicationTest, Register) { | 48 TEST_F(NfcApplicationTest, Register) { |
| 49 nfc_->Register(); | 49 nfc_->Register(); |
| 50 } | 50 } |
| 51 | 51 |
| 52 } // namespace | 52 } // namespace |
| 53 } // namespace mojo | 53 } // namespace mojo |
| OLD | NEW |