| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <deque> | 5 #include <deque> |
| 6 #include <string> | 6 #include <string> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "chrome/browser/extensions/api/api_resource_event_notifier.h" | 10 #include "chrome/browser/extensions/api/api_resource_event_notifier.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 } | 46 } |
| 47 protected: | 47 protected: |
| 48 virtual ~FakeSerialGetPortsFunction() {} | 48 virtual ~FakeSerialGetPortsFunction() {} |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 class FakeEchoSerialConnection : public SerialConnection { | 51 class FakeEchoSerialConnection : public SerialConnection { |
| 52 public: | 52 public: |
| 53 explicit FakeEchoSerialConnection( | 53 explicit FakeEchoSerialConnection( |
| 54 const std::string& port, | 54 const std::string& port, |
| 55 int bitrate, | 55 int bitrate, |
| 56 const std::string& owner_extension_id, |
| 56 ApiResourceEventNotifier* event_notifier) | 57 ApiResourceEventNotifier* event_notifier) |
| 57 : SerialConnection(port, bitrate, event_notifier), | 58 : SerialConnection(port, bitrate, owner_extension_id, event_notifier), |
| 58 opened_(true) { | 59 opened_(true) { |
| 59 Flush(); | 60 Flush(); |
| 60 opened_ = false; | 61 opened_ = false; |
| 61 } | 62 } |
| 62 | 63 |
| 63 virtual ~FakeEchoSerialConnection() { | 64 virtual ~FakeEchoSerialConnection() { |
| 64 } | 65 } |
| 65 | 66 |
| 66 virtual bool Open() { | 67 virtual bool Open() { |
| 67 DCHECK(!opened_); | 68 DCHECK(!opened_); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 std::deque<char> buffer_; | 113 std::deque<char> buffer_; |
| 113 | 114 |
| 114 DISALLOW_COPY_AND_ASSIGN(FakeEchoSerialConnection); | 115 DISALLOW_COPY_AND_ASSIGN(FakeEchoSerialConnection); |
| 115 }; | 116 }; |
| 116 | 117 |
| 117 class FakeSerialOpenFunction : public SerialOpenFunction { | 118 class FakeSerialOpenFunction : public SerialOpenFunction { |
| 118 protected: | 119 protected: |
| 119 virtual SerialConnection* CreateSerialConnection( | 120 virtual SerialConnection* CreateSerialConnection( |
| 120 const std::string& port, | 121 const std::string& port, |
| 121 int bitrate, | 122 int bitrate, |
| 123 const std::string& owner_extension_id, |
| 122 ApiResourceEventNotifier* event_notifier) OVERRIDE { | 124 ApiResourceEventNotifier* event_notifier) OVERRIDE { |
| 123 FakeEchoSerialConnection* serial_connection = | 125 FakeEchoSerialConnection* serial_connection = |
| 124 new FakeEchoSerialConnection(port, bitrate, event_notifier); | 126 new FakeEchoSerialConnection(port, bitrate, owner_extension_id, |
| 127 event_notifier); |
| 125 EXPECT_CALL(*serial_connection, GetControlSignals(_)). | 128 EXPECT_CALL(*serial_connection, GetControlSignals(_)). |
| 126 Times(1).WillOnce(Return(true)); | 129 Times(1).WillOnce(Return(true)); |
| 127 EXPECT_CALL(*serial_connection, SetControlSignals(_)). | 130 EXPECT_CALL(*serial_connection, SetControlSignals(_)). |
| 128 Times(1).WillOnce(Return(true)); | 131 Times(1).WillOnce(Return(true)); |
| 129 return serial_connection; | 132 return serial_connection; |
| 130 } | 133 } |
| 131 virtual bool DoesPortExist(const std::string& port) OVERRIDE { | 134 virtual bool DoesPortExist(const std::string& port) OVERRIDE { |
| 132 return true; | 135 return true; |
| 133 } | 136 } |
| 134 | 137 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 | 184 |
| 182 ASSERT_TRUE(RunExtensionTest("serial/api")) << message_; | 185 ASSERT_TRUE(RunExtensionTest("serial/api")) << message_; |
| 183 } | 186 } |
| 184 | 187 |
| 185 IN_PROC_BROWSER_TEST_F(SerialApiTest, SerialRealHardware) { | 188 IN_PROC_BROWSER_TEST_F(SerialApiTest, SerialRealHardware) { |
| 186 ResultCatcher catcher; | 189 ResultCatcher catcher; |
| 187 catcher.RestrictToProfile(browser()->profile()); | 190 catcher.RestrictToProfile(browser()->profile()); |
| 188 | 191 |
| 189 ASSERT_TRUE(RunExtensionTest("serial/real_hardware")) << message_; | 192 ASSERT_TRUE(RunExtensionTest("serial/real_hardware")) << message_; |
| 190 } | 193 } |
| OLD | NEW |