| 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 #ifndef USE_BRLAPI | 5 #ifndef USE_BRLAPI |
| 6 #error This test requires brlapi. | 6 #error This test requires brlapi. |
| 7 #endif | 7 #endif |
| 8 | 8 |
| 9 #include <deque> | 9 #include <deque> |
| 10 | 10 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 return true; | 81 return true; |
| 82 } | 82 } |
| 83 | 83 |
| 84 virtual bool WriteDots(const unsigned char* cells) OVERRIDE { | 84 virtual bool WriteDots(const unsigned char* cells) OVERRIDE { |
| 85 std::string written(reinterpret_cast<const char*>(cells), | 85 std::string written(reinterpret_cast<const char*>(cells), |
| 86 data_->display_size); | 86 data_->display_size); |
| 87 data_->written_content.push_back(written); | 87 data_->written_content.push_back(written); |
| 88 return true; | 88 return true; |
| 89 } | 89 } |
| 90 | 90 |
| 91 virtual int ReadKey(brlapi_keyCode_t* key_code) { | 91 virtual int ReadKey(brlapi_keyCode_t* key_code) OVERRIDE { |
| 92 if (!data_->pending_keys.empty()) { | 92 if (!data_->pending_keys.empty()) { |
| 93 int queued_key_code = data_->pending_keys.front(); | 93 int queued_key_code = data_->pending_keys.front(); |
| 94 data_->pending_keys.pop_front(); | 94 data_->pending_keys.pop_front(); |
| 95 if (queued_key_code < 0) { | 95 if (queued_key_code < 0) { |
| 96 data_->error.brlerrno = BRLAPI_ERROR_EOF; | 96 data_->error.brlerrno = BRLAPI_ERROR_EOF; |
| 97 return -1; // Signal error. | 97 return -1; // Signal error. |
| 98 } | 98 } |
| 99 *key_code = queued_key_code; | 99 *key_code = queued_key_code; |
| 100 return 1; | 100 return 1; |
| 101 } else { | 101 } else { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 113 base::Unretained(this))); | 113 base::Unretained(this))); |
| 114 } | 114 } |
| 115 } | 115 } |
| 116 | 116 |
| 117 MockBrlapiConnectionData* data_; | 117 MockBrlapiConnectionData* data_; |
| 118 OnDataReadyCallback on_data_ready_; | 118 OnDataReadyCallback on_data_ready_; |
| 119 }; | 119 }; |
| 120 | 120 |
| 121 class BrailleDisplayPrivateApiTest : public ExtensionApiTest { | 121 class BrailleDisplayPrivateApiTest : public ExtensionApiTest { |
| 122 public: | 122 public: |
| 123 virtual void SetUpInProcessBrowserTestFixture() { | 123 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| 124 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); | 124 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); |
| 125 connection_data_.connected = false; | 125 connection_data_.connected = false; |
| 126 connection_data_.display_size = 0; | 126 connection_data_.display_size = 0; |
| 127 connection_data_.error.brlerrno = BRLAPI_ERROR_SUCCESS; | 127 connection_data_.error.brlerrno = BRLAPI_ERROR_SUCCESS; |
| 128 connection_data_.reappear_on_disconnect = false; | 128 connection_data_.reappear_on_disconnect = false; |
| 129 BrailleControllerImpl::GetInstance()->SetCreateBrlapiConnectionForTesting( | 129 BrailleControllerImpl::GetInstance()->SetCreateBrlapiConnectionForTesting( |
| 130 base::Bind( | 130 base::Bind( |
| 131 &BrailleDisplayPrivateApiTest::CreateBrlapiConnection, | 131 &BrailleDisplayPrivateApiTest::CreateBrlapiConnection, |
| 132 base::Unretained(this))); | 132 base::Unretained(this))); |
| 133 } | 133 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 connection_data_.display_size = 11; | 170 connection_data_.display_size = 11; |
| 171 connection_data_.pending_keys.push_back(-1); | 171 connection_data_.pending_keys.push_back(-1); |
| 172 connection_data_.reappear_on_disconnect = true; | 172 connection_data_.reappear_on_disconnect = true; |
| 173 ASSERT_TRUE(RunComponentExtensionTest( | 173 ASSERT_TRUE(RunComponentExtensionTest( |
| 174 "braille_display_private/display_state_changes")); | 174 "braille_display_private/display_state_changes")); |
| 175 } | 175 } |
| 176 | 176 |
| 177 } // namespace braille_display_private | 177 } // namespace braille_display_private |
| 178 } // namespace api | 178 } // namespace api |
| 179 } // namespace extensions | 179 } // namespace extensions |
| OLD | NEW |