@@ -64,6 +64,13 @@ class TestStreamWaitState : public ::testing::Test {
64
64
EXPECT_EQ (Result::ErrorTimeout, result);
65
65
}
66
66
67
+ void checkWaitNonZeroTimeout () {
68
+ StreamState next = StreamState::Unknown;
69
+ int64_t timeout = 200 * kNanosPerMillisecond ; // wait for a state change that will never come
70
+ Result result = mStream ->waitForStateChange (mStream ->getState (), &next, timeout);
71
+ EXPECT_EQ (Result::ErrorTimeout, result);
72
+ }
73
+
67
74
void checkStopWhileWaiting () {
68
75
StreamState next = StreamState::Unknown;
69
76
auto r = mStream ->requestStart ();
@@ -120,6 +127,7 @@ class TestStreamWaitState : public ::testing::Test {
120
127
121
128
};
122
129
130
+ // Test return of error timeout when zero passed as the timeoutNanos.
123
131
TEST_F (TestStreamWaitState, OutputLowWaitZero) {
124
132
ASSERT_TRUE (openStream (Direction::Output, PerformanceMode::LowLatency));
125
133
checkWaitZeroTimeout ();
@@ -150,6 +158,38 @@ TEST_F(TestStreamWaitState, OutputNoneWaitZeroSLES) {
150
158
ASSERT_TRUE (closeStream ());
151
159
}
152
160
161
+ // Test actual timeout.
162
+ TEST_F (TestStreamWaitState, OutputLowWaitNonZero) {
163
+ ASSERT_TRUE (openStream (Direction::Output, PerformanceMode::LowLatency));
164
+ checkWaitNonZeroTimeout ();
165
+ ASSERT_TRUE (closeStream ());
166
+ }
167
+
168
+ TEST_F (TestStreamWaitState, OutputNoneWaitNonZero) {
169
+ ASSERT_TRUE (openStream (Direction::Output, PerformanceMode::None));
170
+ checkWaitNonZeroTimeout ();
171
+ ASSERT_TRUE (closeStream ());
172
+ }
173
+
174
+ TEST_F (TestStreamWaitState, OutputLowWaitNonZeroSLES) {
175
+ AudioStreamBuilder builder;
176
+ builder.setPerformanceMode (PerformanceMode::LowLatency);
177
+ builder.setAudioApi (AudioApi::OpenSLES);
178
+ ASSERT_TRUE (openStream (builder));
179
+ checkWaitNonZeroTimeout ();
180
+ ASSERT_TRUE (closeStream ());
181
+ }
182
+
183
+ TEST_F (TestStreamWaitState, OutputNoneWaitNonZeroSLES) {
184
+ AudioStreamBuilder builder;
185
+ builder.setPerformanceMode (PerformanceMode::None);
186
+ builder.setAudioApi (AudioApi::OpenSLES);
187
+ ASSERT_TRUE (openStream (builder));
188
+ checkWaitNonZeroTimeout ();
189
+ ASSERT_TRUE (closeStream ());
190
+ }
191
+
192
+
153
193
154
194
TEST_F (TestStreamWaitState, OutputLowStopWhileWaiting) {
155
195
ASSERT_TRUE (openStream (Direction::Output, PerformanceMode::LowLatency));
@@ -215,4 +255,4 @@ TEST_F(TestStreamWaitState, OutputLowCloseWhileWaitingSLES) {
215
255
ASSERT_TRUE (openStream (builder));
216
256
checkCloseWhileWaiting ();
217
257
ASSERT_TRUE (closeStream ());
218
- }
258
+ }
0 commit comments