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

Side by Side Diff: chrome/browser/extensions/api/serial/serial_apitest.cc

Issue 10777003: Refactor APIResourceController to ProfileKeyedService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge/antony/fix build. Created 8 years, 5 months 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 (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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "chrome/browser/extensions/api/api_resource_event_notifier.h" 9 #include "chrome/browser/extensions/api/api_resource_event_notifier.h"
10 #include "chrome/browser/extensions/api/serial/serial_api.h" 10 #include "chrome/browser/extensions/api/serial/serial_api.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 } 45 }
46 protected: 46 protected:
47 virtual ~FakeSerialGetPortsFunction() {} 47 virtual ~FakeSerialGetPortsFunction() {}
48 }; 48 };
49 49
50 class FakeEchoSerialConnection : public SerialConnection { 50 class FakeEchoSerialConnection : public SerialConnection {
51 public: 51 public:
52 explicit FakeEchoSerialConnection( 52 explicit FakeEchoSerialConnection(
53 const std::string& port, 53 const std::string& port,
54 int bitrate, 54 int bitrate,
55 APIResourceEventNotifier* event_notifier) 55 ApiResourceEventNotifier* event_notifier)
56 : SerialConnection(port, bitrate, event_notifier), 56 : SerialConnection(port, bitrate, event_notifier),
57 opened_(true) { 57 opened_(true) {
58 Flush(); 58 Flush();
59 opened_ = false; 59 opened_ = false;
60 } 60 }
61 61
62 virtual ~FakeEchoSerialConnection() { 62 virtual ~FakeEchoSerialConnection() {
63 } 63 }
64 64
65 virtual bool Open() { 65 virtual bool Open() {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 int write_index_; 114 int write_index_;
115 115
116 DISALLOW_COPY_AND_ASSIGN(FakeEchoSerialConnection); 116 DISALLOW_COPY_AND_ASSIGN(FakeEchoSerialConnection);
117 }; 117 };
118 118
119 class FakeSerialOpenFunction : public SerialOpenFunction { 119 class FakeSerialOpenFunction : public SerialOpenFunction {
120 protected: 120 protected:
121 virtual SerialConnection* CreateSerialConnection( 121 virtual SerialConnection* CreateSerialConnection(
122 const std::string& port, 122 const std::string& port,
123 int bitrate, 123 int bitrate,
124 APIResourceEventNotifier* event_notifier) OVERRIDE { 124 ApiResourceEventNotifier* event_notifier) OVERRIDE {
125 FakeEchoSerialConnection* serial_connection = 125 FakeEchoSerialConnection* serial_connection =
126 new FakeEchoSerialConnection(port, bitrate, event_notifier); 126 new FakeEchoSerialConnection(port, bitrate, event_notifier);
127 EXPECT_CALL(*serial_connection, GetControlSignals(_)). 127 EXPECT_CALL(*serial_connection, GetControlSignals(_)).
128 Times(1).WillOnce(Return(true)); 128 Times(1).WillOnce(Return(true));
129 EXPECT_CALL(*serial_connection, SetControlSignals(_)). 129 EXPECT_CALL(*serial_connection, SetControlSignals(_)).
130 Times(1).WillOnce(Return(true)); 130 Times(1).WillOnce(Return(true));
131 return serial_connection; 131 return serial_connection;
132 } 132 }
133 virtual bool DoesPortExist(const std::string& port) OVERRIDE { 133 virtual bool DoesPortExist(const std::string& port) OVERRIDE {
134 return true; 134 return true;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 183
184 ASSERT_TRUE(RunExtensionTest("serial/api")) << message_; 184 ASSERT_TRUE(RunExtensionTest("serial/api")) << message_;
185 } 185 }
186 186
187 IN_PROC_BROWSER_TEST_F(SerialApiTest, SerialRealHardware) { 187 IN_PROC_BROWSER_TEST_F(SerialApiTest, SerialRealHardware) {
188 ResultCatcher catcher; 188 ResultCatcher catcher;
189 catcher.RestrictToProfile(browser()->profile()); 189 catcher.RestrictToProfile(browser()->profile());
190 190
191 ASSERT_TRUE(RunExtensionTest("serial/real_hardware")) << message_; 191 ASSERT_TRUE(RunExtensionTest("serial/real_hardware")) << message_;
192 } 192 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/serial/serial_api.cc ('k') | chrome/browser/extensions/api/serial/serial_connection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698