Video sometimes flickers when playing to AppleTV
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Jul 2018 21:02:10 +0000 (21:02 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Jul 2018 21:02:10 +0000 (21:02 +0000)
https://bugs.webkit.org/show_bug.cgi?id=187193
<rdar://problem/40153865>

Unreviewed, fix test broken by r233435.

* TestWebKitAPI/Tests/WebKitLegacy/ios/AudioSessionCategoryIOS.mm:
(TestWebKitAPI::waitUntilAudioSessionCategoryIsEqualTo): Poll for a change in audio session
category because it doesn't necessarily happen synchronously.
(TestWebKitAPI::TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@233478 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKitLegacy/ios/AudioSessionCategoryIOS.mm

index 319df11..31c13a0 100644 (file)
@@ -1,3 +1,16 @@
+2018-07-03  Eric Carlson  <eric.carlson@apple.com>
+
+        Video sometimes flickers when playing to AppleTV
+        https://bugs.webkit.org/show_bug.cgi?id=187193
+        <rdar://problem/40153865>
+
+        Unreviewed, fix test broken by r233435.
+
+        * TestWebKitAPI/Tests/WebKitLegacy/ios/AudioSessionCategoryIOS.mm:
+        (TestWebKitAPI::waitUntilAudioSessionCategoryIsEqualTo): Poll for a change in audio session 
+        category because it doesn't necessarily happen synchronously.
+        (TestWebKitAPI::TEST):
+
 2018-07-03  Thibault Saunier  <tsaunier@igalia.com>
 
         Unreviewed, add myself as a WebKit committer.
index 72c5dac..3839f18 100644 (file)
@@ -59,6 +59,16 @@ static bool didBeginPlaying = false;
 
 namespace TestWebKitAPI {
 
+static void waitUntilAudioSessionCategoryIsEqualTo(NSString *expectedValue)
+{
+    int tries = 0;
+    do {
+        if ([[[getAVAudioSessionClass() sharedInstance] category] isEqualToString:expectedValue])
+            return;
+        Util::sleep(0.1);
+    } while (++tries <= 100);
+}
+
 TEST(WebKitLegacy, AudioSessionCategoryIOS)
 {
     WebCore::DeprecatedGlobalSettings::setShouldManageAudioSessionCategory(true);
@@ -76,6 +86,7 @@ TEST(WebKitLegacy, AudioSessionCategoryIOS)
 
     Util::run(&didBeginPlaying);
 
+    waitUntilAudioSessionCategoryIsEqualTo(getAVAudioSessionCategoryPlayback());
     EXPECT_WK_STREQ(getAVAudioSessionCategoryPlayback(), [[getAVAudioSessionClass() sharedInstance] category]);
 
     didBeginPlaying = false;
@@ -84,6 +95,7 @@ TEST(WebKitLegacy, AudioSessionCategoryIOS)
 
     Util::run(&didBeginPlaying);
 
+    waitUntilAudioSessionCategoryIsEqualTo(getAVAudioSessionCategoryAmbient());
     EXPECT_WK_STREQ(getAVAudioSessionCategoryAmbient(), [[getAVAudioSessionClass() sharedInstance] category]);
 
     didBeginPlaying = false;
@@ -92,6 +104,7 @@ TEST(WebKitLegacy, AudioSessionCategoryIOS)
 
     Util::run(&didBeginPlaying);
 
+    waitUntilAudioSessionCategoryIsEqualTo(getAVAudioSessionCategoryAmbient());
     EXPECT_WK_STREQ(getAVAudioSessionCategoryAmbient(), [[getAVAudioSessionClass() sharedInstance] category]);
 
     didBeginPlaying = false;
@@ -100,6 +113,7 @@ TEST(WebKitLegacy, AudioSessionCategoryIOS)
 
     Util::run(&didBeginPlaying);
 
+    waitUntilAudioSessionCategoryIsEqualTo(getAVAudioSessionCategoryAmbient());
     EXPECT_WK_STREQ(getAVAudioSessionCategoryAmbient(), [[getAVAudioSessionClass() sharedInstance] category]);
 
     didBeginPlaying = false;
@@ -108,6 +122,7 @@ TEST(WebKitLegacy, AudioSessionCategoryIOS)
 
     Util::run(&didBeginPlaying);
 
+    waitUntilAudioSessionCategoryIsEqualTo(getAVAudioSessionCategoryAmbient());
     EXPECT_WK_STREQ(getAVAudioSessionCategoryAmbient(), [[getAVAudioSessionClass() sharedInstance] category]);
 }