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

Side by Side Diff: media/midi/midi_manager_unittest.cc

Issue 655713003: Standardize usage of virtual/override/final in media/ (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 | « media/midi/midi_manager_mac.h ('k') | media/midi/midi_manager_usb.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 "media/midi/midi_manager.h" 5 #include "media/midi/midi_manager.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/run_loop.h" 14 #include "base/run_loop.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 namespace media { 17 namespace media {
18 18
19 namespace { 19 namespace {
20 20
21 class FakeMidiManager : public MidiManager { 21 class FakeMidiManager : public MidiManager {
22 public: 22 public:
23 FakeMidiManager() : start_initialization_is_called_(false) {} 23 FakeMidiManager() : start_initialization_is_called_(false) {}
24 virtual ~FakeMidiManager() {} 24 ~FakeMidiManager() override {}
25 25
26 // MidiManager implementation. 26 // MidiManager implementation.
27 virtual void StartInitialization() override { 27 void StartInitialization() override {
28 start_initialization_is_called_ = true; 28 start_initialization_is_called_ = true;
29 } 29 }
30 30
31 virtual void DispatchSendMidiData(MidiManagerClient* client, 31 void DispatchSendMidiData(MidiManagerClient* client,
32 uint32 port_index, 32 uint32 port_index,
33 const std::vector<uint8>& data, 33 const std::vector<uint8>& data,
34 double timestamp) override {} 34 double timestamp) override {}
35 35
36 // Utility functions for testing. 36 // Utility functions for testing.
37 void CallCompleteInitialization(MidiResult result) { 37 void CallCompleteInitialization(MidiResult result) {
38 CompleteInitialization(result); 38 CompleteInitialization(result);
39 } 39 }
40 40
41 size_t GetClientCount() const { 41 size_t GetClientCount() const {
42 return clients_size_for_testing(); 42 return clients_size_for_testing();
43 } 43 }
44 44
45 size_t GetPendingClientCount() const { 45 size_t GetPendingClientCount() const {
46 return pending_clients_size_for_testing(); 46 return pending_clients_size_for_testing();
47 } 47 }
48 48
49 bool start_initialization_is_called_; 49 bool start_initialization_is_called_;
50 50
51 private: 51 private:
52 DISALLOW_COPY_AND_ASSIGN(FakeMidiManager); 52 DISALLOW_COPY_AND_ASSIGN(FakeMidiManager);
53 }; 53 };
54 54
55 class FakeMidiManagerClient : public MidiManagerClient { 55 class FakeMidiManagerClient : public MidiManagerClient {
56 public: 56 public:
57 explicit FakeMidiManagerClient(int client_id) 57 explicit FakeMidiManagerClient(int client_id)
58 : client_id_(client_id), 58 : client_id_(client_id),
59 result_(MIDI_NOT_SUPPORTED), 59 result_(MIDI_NOT_SUPPORTED),
60 wait_for_result_(true) {} 60 wait_for_result_(true) {}
61 virtual ~FakeMidiManagerClient() {} 61 ~FakeMidiManagerClient() override {}
62 62
63 // MidiManagerClient implementation. 63 // MidiManagerClient implementation.
64 virtual void CompleteStartSession(int client_id, MidiResult result) override { 64 void CompleteStartSession(int client_id, MidiResult result) override {
65 EXPECT_TRUE(wait_for_result_); 65 EXPECT_TRUE(wait_for_result_);
66 CHECK_EQ(client_id_, client_id); 66 CHECK_EQ(client_id_, client_id);
67 result_ = result; 67 result_ = result;
68 wait_for_result_ = false; 68 wait_for_result_ = false;
69 } 69 }
70 70
71 virtual void ReceiveMidiData(uint32 port_index, const uint8* data, 71 void ReceiveMidiData(uint32 port_index,
72 size_t size, double timestamp) override {} 72 const uint8* data,
73 virtual void AccumulateMidiBytesSent(size_t size) override {} 73 size_t size,
74 double timestamp) override {}
75 void AccumulateMidiBytesSent(size_t size) override {}
74 76
75 int client_id() const { return client_id_; } 77 int client_id() const { return client_id_; }
76 MidiResult result() const { return result_; } 78 MidiResult result() const { return result_; }
77 79
78 MidiResult WaitForResult() { 80 MidiResult WaitForResult() {
79 while (wait_for_result_) { 81 while (wait_for_result_) {
80 base::RunLoop run_loop; 82 base::RunLoop run_loop;
81 run_loop.RunUntilIdle(); 83 run_loop.RunUntilIdle();
82 } 84 }
83 return result(); 85 return result();
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 // Temporary until http://crbug.com/371230 is resolved. 261 // Temporary until http://crbug.com/371230 is resolved.
260 EXPECT_TRUE((result == MIDI_OK) || (result == MIDI_INITIALIZATION_ERROR)); 262 EXPECT_TRUE((result == MIDI_OK) || (result == MIDI_INITIALIZATION_ERROR));
261 #else 263 #else
262 EXPECT_EQ(MIDI_OK, result); 264 EXPECT_EQ(MIDI_OK, result);
263 #endif 265 #endif
264 } 266 }
265 267
266 } // namespace 268 } // namespace
267 269
268 } // namespace media 270 } // namespace media
OLDNEW
« no previous file with comments | « media/midi/midi_manager_mac.h ('k') | media/midi/midi_manager_usb.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698