| 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 "extensions/browser/api/webcam_private/visca_webcam.h" |
| 6 |
| 5 #include <vector> | 7 #include <vector> |
| 6 | 8 |
| 7 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ptr_util.h" |
| 8 #include "content/public/test/test_browser_thread_bundle.h" | 11 #include "content/public/test/test_browser_thread_bundle.h" |
| 9 #include "extensions/browser/api/webcam_private/visca_webcam.h" | |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 13 |
| 12 namespace extensions { | 14 namespace extensions { |
| 13 | 15 |
| 14 namespace { | 16 namespace { |
| 15 | 17 |
| 16 class TestSerialConnection : public SerialConnection { | 18 class TestSerialConnection : public SerialConnection { |
| 17 public: | 19 public: |
| 18 TestSerialConnection() : SerialConnection("dummy_path", "dummy_id") {} | 20 TestSerialConnection() : SerialConnection("dummy_path", "dummy_id") {} |
| 19 ~TestSerialConnection() override {} | 21 ~TestSerialConnection() override {} |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 | 87 |
| 86 #define CHAR_VECTOR_FROM_ARRAY(array) \ | 88 #define CHAR_VECTOR_FROM_ARRAY(array) \ |
| 87 std::vector<char>(array, array + arraysize(array)) | 89 std::vector<char>(array, array + arraysize(array)) |
| 88 | 90 |
| 89 } // namespace | 91 } // namespace |
| 90 | 92 |
| 91 class ViscaWebcamTest : public testing::Test { | 93 class ViscaWebcamTest : public testing::Test { |
| 92 protected: | 94 protected: |
| 93 ViscaWebcamTest() { | 95 ViscaWebcamTest() { |
| 94 webcam_ = new ViscaWebcam; | 96 webcam_ = new ViscaWebcam; |
| 95 webcam_->OpenForTesting(make_scoped_ptr(new TestSerialConnection)); | 97 webcam_->OpenForTesting(base::WrapUnique(new TestSerialConnection)); |
| 96 } | 98 } |
| 97 ~ViscaWebcamTest() override {} | 99 ~ViscaWebcamTest() override {} |
| 98 | 100 |
| 99 Webcam* webcam() { return webcam_.get(); } | 101 Webcam* webcam() { return webcam_.get(); } |
| 100 | 102 |
| 101 TestSerialConnection* serial_connection() { | 103 TestSerialConnection* serial_connection() { |
| 102 return static_cast<TestSerialConnection*>( | 104 return static_cast<TestSerialConnection*>( |
| 103 webcam_->GetSerialConnectionForTesting()); | 105 webcam_->GetSerialConnectionForTesting()); |
| 104 } | 106 } |
| 105 | 107 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 132 base::Bind(&SetPTZExpectations::OnCallback, | 134 base::Bind(&SetPTZExpectations::OnCallback, |
| 133 base::Owned(new SetPTZExpectations(true))); | 135 base::Owned(new SetPTZExpectations(true))); |
| 134 serial_connection()->SetReceiveBuffer( | 136 serial_connection()->SetReceiveBuffer( |
| 135 CHAR_VECTOR_FROM_ARRAY(kSetZoomResponse)); | 137 CHAR_VECTOR_FROM_ARRAY(kSetZoomResponse)); |
| 136 webcam()->SetZoom(0x6253, send_callback); | 138 webcam()->SetZoom(0x6253, send_callback); |
| 137 serial_connection()->CheckSendBufferAndClear( | 139 serial_connection()->CheckSendBufferAndClear( |
| 138 CHAR_VECTOR_FROM_ARRAY(kSetZoomCommand)); | 140 CHAR_VECTOR_FROM_ARRAY(kSetZoomCommand)); |
| 139 } | 141 } |
| 140 | 142 |
| 141 } // namespace extensions | 143 } // namespace extensions |
| OLD | NEW |