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

Unified Diff: media/midi/midi_manager_unittest.cc

Issue 2404443002: Web MIDI: use midi_service.mojom for media::midi::Result (Closed)
Patch Set: rebase Created 4 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 side-by-side diff with in-line comments
Download patch
Index: media/midi/midi_manager_unittest.cc
diff --git a/media/midi/midi_manager_unittest.cc b/media/midi/midi_manager_unittest.cc
index eed774d667e5814151489043bbf2b63a01a328fd..86d2bd1268e57810c393678cb8b32b2410a17d2b 100644
--- a/media/midi/midi_manager_unittest.cc
+++ b/media/midi/midi_manager_unittest.cc
@@ -43,7 +43,7 @@ class FakeMidiManager : public MidiManager {
double timestamp) override {}
// Utility functions for testing.
- void CallCompleteInitialization(Result result) {
+ void CallCompleteInitialization(mojom::Result result) {
CompleteInitialization(result);
}
@@ -65,7 +65,7 @@ class FakeMidiManager : public MidiManager {
class FakeMidiManagerClient : public MidiManagerClient {
public:
FakeMidiManagerClient()
- : result_(Result::NOT_SUPPORTED), wait_for_result_(true) {}
+ : result_(mojom::Result::NOT_SUPPORTED), wait_for_result_(true) {}
~FakeMidiManagerClient() override {}
// MidiManagerClient implementation.
@@ -74,7 +74,7 @@ class FakeMidiManagerClient : public MidiManagerClient {
void SetInputPortState(uint32_t port_index, MidiPortState state) override {}
void SetOutputPortState(uint32_t port_index, MidiPortState state) override {}
- void CompleteStartSession(Result result) override {
+ void CompleteStartSession(mojom::Result result) override {
EXPECT_TRUE(wait_for_result_);
result_ = result;
wait_for_result_ = false;
@@ -87,9 +87,9 @@ class FakeMidiManagerClient : public MidiManagerClient {
void AccumulateMidiBytesSent(size_t size) override {}
void Detach() override {}
- Result result() const { return result_; }
+ mojom::Result result() const { return result_; }
- Result WaitForResult() {
+ mojom::Result WaitForResult() {
while (wait_for_result_) {
base::RunLoop run_loop;
run_loop.RunUntilIdle();
@@ -98,7 +98,7 @@ class FakeMidiManagerClient : public MidiManagerClient {
}
private:
- Result result_;
+ mojom::Result result_;
bool wait_for_result_;
DISALLOW_COPY_AND_ASSIGN(FakeMidiManagerClient);
@@ -150,7 +150,7 @@ class MidiManagerTest : public ::testing::Test {
EXPECT_EQ(after, manager_->GetClientCount());
}
- void CompleteInitialization(Result result) {
+ void CompleteInitialization(mojom::Result result) {
manager_->CallCompleteInitialization(result);
}
@@ -173,8 +173,8 @@ TEST_F(MidiManagerTest, StartAndEndSession) {
client.reset(new FakeMidiManagerClient);
StartTheFirstSession(client.get());
- CompleteInitialization(Result::OK);
- EXPECT_EQ(Result::OK, client->WaitForResult());
+ CompleteInitialization(mojom::Result::OK);
+ EXPECT_EQ(mojom::Result::OK, client->WaitForResult());
EndSession(client.get(), 1U, 0U);
}
@@ -183,8 +183,8 @@ TEST_F(MidiManagerTest, StartAndEndSessionWithError) {
client.reset(new FakeMidiManagerClient);
StartTheFirstSession(client.get());
- CompleteInitialization(Result::INITIALIZATION_ERROR);
- EXPECT_EQ(Result::INITIALIZATION_ERROR, client->WaitForResult());
+ CompleteInitialization(mojom::Result::INITIALIZATION_ERROR);
+ EXPECT_EQ(mojom::Result::INITIALIZATION_ERROR, client->WaitForResult());
EndSession(client.get(), 0U, 0U);
}
@@ -199,10 +199,10 @@ TEST_F(MidiManagerTest, StartMultipleSessions) {
StartTheFirstSession(client1.get());
StartTheNthSession(client2.get(), 2);
StartTheNthSession(client3.get(), 3);
- CompleteInitialization(Result::OK);
- EXPECT_EQ(Result::OK, client1->WaitForResult());
- EXPECT_EQ(Result::OK, client2->WaitForResult());
- EXPECT_EQ(Result::OK, client3->WaitForResult());
+ CompleteInitialization(mojom::Result::OK);
+ EXPECT_EQ(mojom::Result::OK, client1->WaitForResult());
+ EXPECT_EQ(mojom::Result::OK, client2->WaitForResult());
+ EXPECT_EQ(mojom::Result::OK, client3->WaitForResult());
EndSession(client1.get(), 3U, 2U);
EndSession(client2.get(), 2U, 1U);
EndSession(client3.get(), 1U, 0U);
@@ -228,17 +228,17 @@ TEST_F(MidiManagerTest, TooManyPendingSessions) {
manager_->StartSession(additional_client.get());
EXPECT_FALSE(manager_->start_initialization_is_called_);
manager_->start_initialization_is_called_ = true;
- EXPECT_EQ(Result::INITIALIZATION_ERROR, additional_client->result());
+ EXPECT_EQ(mojom::Result::INITIALIZATION_ERROR, additional_client->result());
// Other clients still should not receive a result.
RunLoopUntilIdle();
for (size_t i = 0; i < many_existing_clients.size(); ++i)
- EXPECT_EQ(Result::NOT_SUPPORTED, many_existing_clients[i]->result());
+ EXPECT_EQ(mojom::Result::NOT_SUPPORTED, many_existing_clients[i]->result());
- // The Result::OK should be distributed to other clients.
- CompleteInitialization(Result::OK);
+ // The mojom::Result::OK should be distributed to other clients.
+ CompleteInitialization(mojom::Result::OK);
for (size_t i = 0; i < many_existing_clients.size(); ++i)
- EXPECT_EQ(Result::OK, many_existing_clients[i]->WaitForResult());
+ EXPECT_EQ(mojom::Result::OK, many_existing_clients[i]->WaitForResult());
// Close all successful sessions in FIFO order.
size_t sessions = many_existing_clients.size();
@@ -257,7 +257,7 @@ TEST_F(MidiManagerTest, AbortSession) {
client.reset();
// Following function should not call the destructed |client| function.
- CompleteInitialization(Result::OK);
+ CompleteInitialization(mojom::Result::OK);
base::RunLoop run_loop;
run_loop.RunUntilIdle();
}
@@ -272,17 +272,18 @@ TEST_F(MidiManagerTest, CreateMidiManager) {
std::unique_ptr<MidiManager> manager(MidiManager::Create());
manager->StartSession(client.get());
- Result result = client->WaitForResult();
+ mojom::Result result = client->WaitForResult();
// This #ifdef needs to be identical to the one in media/midi/midi_manager.cc.
// Do not change the condition for disabling this test.
#if !defined(OS_MACOSX) && !defined(OS_WIN) && \
!(defined(USE_ALSA) && defined(USE_UDEV)) && !defined(OS_ANDROID)
- EXPECT_EQ(Result::NOT_SUPPORTED, result);
+ EXPECT_EQ(mojom::Result::NOT_SUPPORTED, result);
#elif defined(USE_ALSA)
// Temporary until http://crbug.com/371230 is resolved.
- EXPECT_TRUE(result == Result::OK || result == Result::INITIALIZATION_ERROR);
+ EXPECT_TRUE(result == mojom::Result::OK ||
+ result == mojom::Result::INITIALIZATION_ERROR);
#else
- EXPECT_EQ(Result::OK, result);
+ EXPECT_EQ(mojom::Result::OK, result);
#endif
manager->Shutdown();

Powered by Google App Engine
This is Rietveld 408576698