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

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

Issue 1056333002: Web MIDI: Improve device change monitornig on Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: SystemMonitor in test Created 5 years, 8 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 | « no previous file | media/midi/midi_manager_win.cc » ('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 "base/system_monitor/system_monitor.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 17
17 namespace media { 18 namespace media {
18 19
19 namespace { 20 namespace {
20 21
21 class FakeMidiManager : public MidiManager { 22 class FakeMidiManager : public MidiManager {
22 public: 23 public:
23 FakeMidiManager() : start_initialization_is_called_(false) {} 24 FakeMidiManager() : start_initialization_is_called_(false) {}
24 ~FakeMidiManager() override {} 25 ~FakeMidiManager() override {}
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 EndSession(client.get(), 0, 0); 239 EndSession(client.get(), 0, 0);
239 client.reset(); 240 client.reset();
240 241
241 // Following function should not call the destructed |client| function. 242 // Following function should not call the destructed |client| function.
242 CompleteInitialization(MIDI_OK); 243 CompleteInitialization(MIDI_OK);
243 base::RunLoop run_loop; 244 base::RunLoop run_loop;
244 run_loop.RunUntilIdle(); 245 run_loop.RunUntilIdle();
245 } 246 }
246 247
247 TEST_F(MidiManagerTest, CreateMidiManager) { 248 TEST_F(MidiManagerTest, CreateMidiManager) {
249 // SystemMonitor is needed on Windows.
250 base::SystemMonitor system_monitor;
251
248 scoped_ptr<FakeMidiManagerClient> client; 252 scoped_ptr<FakeMidiManagerClient> client;
249 client.reset(new FakeMidiManagerClient); 253 client.reset(new FakeMidiManagerClient);
250 254
251 scoped_ptr<MidiManager> manager(MidiManager::Create()); 255 scoped_ptr<MidiManager> manager(MidiManager::Create());
252 manager->StartSession(client.get()); 256 manager->StartSession(client.get());
253 257
254 MidiResult result = client->WaitForResult(); 258 MidiResult result = client->WaitForResult();
255 // This #ifdef needs to be identical to the one in media/midi/midi_manager.cc. 259 // This #ifdef needs to be identical to the one in media/midi/midi_manager.cc.
256 // Do not change the condition for disabling this test. 260 // Do not change the condition for disabling this test.
257 #if !defined(OS_MACOSX) && !defined(OS_WIN) && !defined(USE_ALSA) && \ 261 #if !defined(OS_MACOSX) && !defined(OS_WIN) && !defined(USE_ALSA) && \
258 !defined(OS_ANDROID) && !defined(OS_CHROMEOS) 262 !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
259 EXPECT_EQ(MIDI_NOT_SUPPORTED, result); 263 EXPECT_EQ(MIDI_NOT_SUPPORTED, result);
260 #elif defined(USE_ALSA) 264 #elif defined(USE_ALSA)
261 // Temporary until http://crbug.com/371230 is resolved. 265 // Temporary until http://crbug.com/371230 is resolved.
262 EXPECT_TRUE((result == MIDI_OK) || (result == MIDI_INITIALIZATION_ERROR)); 266 EXPECT_TRUE((result == MIDI_OK) || (result == MIDI_INITIALIZATION_ERROR));
263 #else 267 #else
264 EXPECT_EQ(MIDI_OK, result); 268 EXPECT_EQ(MIDI_OK, result);
265 #endif 269 #endif
266 } 270 }
267 271
268 } // namespace 272 } // namespace
269 273
270 } // namespace media 274 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/midi/midi_manager_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698