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

Side by Side Diff: extensions/browser/api/usb/usb_apitest.cc

Issue 664933004: Standardize usage of virtual/override/final in extensions/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « extensions/browser/api/usb/usb_api.h ('k') | extensions/browser/api/usb/usb_device_resource.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/extensions/extension_apitest.h" 5 #include "chrome/browser/extensions/extension_apitest.h"
6 #include "chrome/browser/ui/browser.h" 6 #include "chrome/browser/ui/browser.h"
7 #include "content/public/browser/browser_thread.h" 7 #include "content/public/browser/browser_thread.h"
8 #include "content/public/test/test_utils.h" 8 #include "content/public/test/test_utils.h"
9 #include "device/usb/usb_service.h" 9 #include "device/usb/usb_service.h"
10 #include "extensions/browser/api/usb/usb_api.h" 10 #include "extensions/browser/api/usb/usb_api.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 private: 138 private:
139 MockUsbDeviceHandle* mock_handle_; 139 MockUsbDeviceHandle* mock_handle_;
140 virtual ~MockUsbDevice() {} 140 virtual ~MockUsbDevice() {}
141 }; 141 };
142 142
143 class MockUsbService : public UsbService { 143 class MockUsbService : public UsbService {
144 public: 144 public:
145 explicit MockUsbService(scoped_refptr<UsbDevice> device) : device_(device) {} 145 explicit MockUsbService(scoped_refptr<UsbDevice> device) : device_(device) {}
146 146
147 protected: 147 protected:
148 virtual scoped_refptr<UsbDevice> GetDeviceById(uint32 unique_id) override { 148 scoped_refptr<UsbDevice> GetDeviceById(uint32 unique_id) override {
149 EXPECT_EQ(unique_id, 0U); 149 EXPECT_EQ(unique_id, 0U);
150 return device_; 150 return device_;
151 } 151 }
152 152
153 virtual void GetDevices( 153 void GetDevices(std::vector<scoped_refptr<UsbDevice>>* devices) override {
154 std::vector<scoped_refptr<UsbDevice> >* devices) override {
155 STLClearObject(devices); 154 STLClearObject(devices);
156 devices->push_back(device_); 155 devices->push_back(device_);
157 } 156 }
158 157
159 scoped_refptr<UsbDevice> device_; 158 scoped_refptr<UsbDevice> device_;
160 }; 159 };
161 160
162 #if defined(OS_WIN) 161 #if defined(OS_WIN)
163 #pragma warning(pop) 162 #pragma warning(pop)
164 #endif 163 #endif
165 164
166 class UsbApiTest : public ExtensionApiTest { 165 class UsbApiTest : public ExtensionApiTest {
167 public: 166 public:
168 virtual void SetUpOnMainThread() override { 167 void SetUpOnMainThread() override {
169 mock_device_handle_ = new MockUsbDeviceHandle(); 168 mock_device_handle_ = new MockUsbDeviceHandle();
170 mock_device_ = new MockUsbDevice(mock_device_handle_.get()); 169 mock_device_ = new MockUsbDevice(mock_device_handle_.get());
171 scoped_refptr<content::MessageLoopRunner> runner = 170 scoped_refptr<content::MessageLoopRunner> runner =
172 new content::MessageLoopRunner; 171 new content::MessageLoopRunner;
173 BrowserThread::PostTaskAndReply(BrowserThread::FILE, 172 BrowserThread::PostTaskAndReply(BrowserThread::FILE,
174 FROM_HERE, 173 FROM_HERE,
175 base::Bind(&UsbApiTest::SetUpService, this), 174 base::Bind(&UsbApiTest::SetUpService, this),
176 runner->QuitClosure()); 175 runner->QuitClosure());
177 runner->Run(); 176 runner->Run();
178 } 177 }
179 178
180 void SetUpService() { 179 void SetUpService() {
181 UsbService::SetInstanceForTest(new MockUsbService(mock_device_)); 180 UsbService::SetInstanceForTest(new MockUsbService(mock_device_));
182 } 181 }
183 182
184 virtual void TearDownOnMainThread() override { 183 void TearDownOnMainThread() override {
185 scoped_refptr<content::MessageLoopRunner> runner = 184 scoped_refptr<content::MessageLoopRunner> runner =
186 new content::MessageLoopRunner; 185 new content::MessageLoopRunner;
187 UsbService* service = NULL; 186 UsbService* service = NULL;
188 BrowserThread::PostTaskAndReply( 187 BrowserThread::PostTaskAndReply(
189 BrowserThread::FILE, 188 BrowserThread::FILE,
190 FROM_HERE, 189 FROM_HERE,
191 base::Bind(&UsbService::SetInstanceForTest, service), 190 base::Bind(&UsbService::SetInstanceForTest, service),
192 runner->QuitClosure()); 191 runner->QuitClosure());
193 runner->Run(); 192 runner->Run();
194 } 193 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 .WillOnce(InvokeUsbTransferCallback<5>(device::USB_TRANSFER_ERROR)) 263 .WillOnce(InvokeUsbTransferCallback<5>(device::USB_TRANSFER_ERROR))
265 .WillOnce(InvokeUsbTransferCallback<5>(device::USB_TRANSFER_TIMEOUT)); 264 .WillOnce(InvokeUsbTransferCallback<5>(device::USB_TRANSFER_TIMEOUT));
266 EXPECT_CALL(*mock_device_handle_.get(), Close()).Times(AnyNumber()); 265 EXPECT_CALL(*mock_device_handle_.get(), Close()).Times(AnyNumber());
267 ASSERT_TRUE(RunExtensionTest("usb/transfer_failure")); 266 ASSERT_TRUE(RunExtensionTest("usb/transfer_failure"));
268 } 267 }
269 268
270 IN_PROC_BROWSER_TEST_F(UsbApiTest, InvalidLengthTransfer) { 269 IN_PROC_BROWSER_TEST_F(UsbApiTest, InvalidLengthTransfer) {
271 EXPECT_CALL(*mock_device_handle_.get(), Close()).Times(AnyNumber()); 270 EXPECT_CALL(*mock_device_handle_.get(), Close()).Times(AnyNumber());
272 ASSERT_TRUE(RunExtensionTest("usb/invalid_length_transfer")); 271 ASSERT_TRUE(RunExtensionTest("usb/invalid_length_transfer"));
273 } 272 }
OLDNEW
« no previous file with comments | « extensions/browser/api/usb/usb_api.h ('k') | extensions/browser/api/usb/usb_device_resource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698