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

Unified Diff: media/midi/midi_manager_unittest.cc

Issue 323323002: Web MIDI: MidiManager crashes if a session is ended while initializing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: make_pair Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/midi/midi_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/midi/midi_manager_unittest.cc
diff --git a/media/midi/midi_manager_unittest.cc b/media/midi/midi_manager_unittest.cc
index c129ca1779d6f9e0c2bebef928947bd23bf5e02f..03508139db117437a4f7677b73df7f79a2b7481a 100644
--- a/media/midi/midi_manager_unittest.cc
+++ b/media/midi/midi_manager_unittest.cc
@@ -171,18 +171,26 @@ TEST_F(MidiManagerTest, StartAndEndSessionWithError) {
TEST_F(MidiManagerTest, StartMultipleSessions) {
scoped_ptr<FakeMidiManagerClient> client1;
scoped_ptr<FakeMidiManagerClient> client2;
+ scoped_ptr<FakeMidiManagerClient> client3;
client1.reset(new FakeMidiManagerClient(0));
client2.reset(new FakeMidiManagerClient(1));
+ client3.reset(new FakeMidiManagerClient(1));
StartTheFirstSession(client1.get());
StartTheNthSession(client2.get(), 2);
+ StartTheNthSession(client3.get(), 3);
CompleteInitialization(MIDI_OK);
EXPECT_EQ(MIDI_OK, client1->WaitForResult());
EXPECT_EQ(MIDI_OK, client2->WaitForResult());
- EndSession(client1.get(), 2U, 1U);
- EndSession(client2.get(), 1U, 0U);
+ EXPECT_EQ(MIDI_OK, client3->WaitForResult());
+ EndSession(client1.get(), 3U, 2U);
+ EndSession(client2.get(), 2U, 1U);
+ EndSession(client3.get(), 1U, 0U);
}
+// TODO(toyoshim): Add a test for a MidiManagerClient that has multiple
+// sessions with multiple client_id.
+
TEST_F(MidiManagerTest, TooManyPendingSessions) {
// Push as many client requests for starting session as possible.
ScopedVector<FakeMidiManagerClient> many_existing_clients;
@@ -217,6 +225,22 @@ TEST_F(MidiManagerTest, TooManyPendingSessions) {
EndSession(many_existing_clients[i], sessions, sessions - 1);
}
+TEST_F(MidiManagerTest, AbortSession) {
+ // A client starting a session can be destructed while an asynchronous
+ // initialization is performed.
+ scoped_ptr<FakeMidiManagerClient> client;
+ client.reset(new FakeMidiManagerClient(0));
+
+ StartTheFirstSession(client.get());
+ EndSession(client.get(), 0, 0);
+ client.reset();
+
+ // Following function should not call the destructed |client| function.
+ CompleteInitialization(MIDI_OK);
+ base::RunLoop run_loop;
+ run_loop.RunUntilIdle();
+}
+
TEST_F(MidiManagerTest, CreateMidiManager) {
scoped_ptr<FakeMidiManagerClient> client;
client.reset(new FakeMidiManagerClient(0));
« no previous file with comments | « media/midi/midi_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698