Caleb Raitto | 17b55dc | 2021-02-01 22:28:37 | [diff] [blame] | 1 | // Copyright 2021 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "build/build_config.h" |
| 6 | #include "chrome/test/base/chrome_test_utils.h" |
| 7 | #include "content/public/test/browser_test.h" |
| 8 | #include "content/public/test/browser_test_utils.h" |
| 9 | #include "testing/gtest/include/gtest/gtest.h" |
| 10 | |
| 11 | #if defined(OS_ANDROID) |
| 12 | #include "chrome/test/base/android/android_browser_test.h" |
| 13 | #else |
| 14 | #include "chrome/test/base/in_process_browser_test.h" |
| 15 | #endif |
| 16 | |
Caleb Raitto | 0c633ff | 2021-02-02 10:55:29 | [diff] [blame^] | 17 | // TODO(crbug.com/1173300): Investigate why different macOS versions have |
| 18 | // different fingerprints. |
| 19 | #if defined(OS_MAC) |
| 20 | #define MAYBE_VerifyDynamicsCompressorFingerprint \ |
| 21 | DISABLED_VerifyDynamicsCompressorFingerprint |
| 22 | #else |
| 23 | #define MAYBE_VerifyDynamicsCompressorFingerprint \ |
| 24 | VerifyDynamicsCompressorFingerprint |
| 25 | #endif |
| 26 | |
Caleb Raitto | 17b55dc | 2021-02-01 22:28:37 | [diff] [blame] | 27 | namespace { |
| 28 | |
| 29 | // This test runs on Android as well as desktop platforms. |
| 30 | class WebAudioBrowserTest : public PlatformBrowserTest { |
| 31 | public: |
| 32 | content::WebContents* web_contents() { |
| 33 | return chrome_test_utils::GetActiveWebContents(this); |
| 34 | } |
| 35 | }; |
| 36 | |
| 37 | IN_PROC_BROWSER_TEST_F(WebAudioBrowserTest, |
Caleb Raitto | 0c633ff | 2021-02-02 10:55:29 | [diff] [blame^] | 38 | MAYBE_VerifyDynamicsCompressorFingerprint) { |
Caleb Raitto | 17b55dc | 2021-02-01 22:28:37 | [diff] [blame] | 39 | ASSERT_TRUE(embedded_test_server()->Start()); |
| 40 | content::DOMMessageQueue messages; |
| 41 | base::RunLoop run_loop; |
| 42 | |
| 43 | ASSERT_TRUE(content::NavigateToURL( |
| 44 | web_contents(), |
| 45 | embedded_test_server()->GetURL( |
| 46 | "/webaudio/calls_dynamics_compressor_fingerprint.html"))); |
| 47 | |
| 48 | // The document computes the DynamicsCompressor fingerprint and sends a |
| 49 | // message back to the test. Receipt of the message indicates that the script |
| 50 | // successfully completed. |
| 51 | std::string fingerprint; |
| 52 | ASSERT_TRUE(messages.WaitForMessage(&fingerprint)); |
| 53 | |
| 54 | // NOTE: Changes to Web Audio code that alter the below fingerprints are |
| 55 | // fine, and are cause for updating these expectations -- the issue is if |
| 56 | // different devices return different fingerprints. |
| 57 | #if defined(OS_ANDROID) && defined(ARCH_CPU_ARM64) |
| 58 | // TODO(crbug.com/1156752): Investigate why this fingerprint is different. |
| 59 | EXPECT_EQ("13.13046550525678", fingerprint); |
| 60 | #else |
| 61 | EXPECT_EQ("13.130926895706125", fingerprint); |
| 62 | #endif // defined(OS_ANDROID) && defined(ARCH_CPU_ARM64) |
| 63 | } |
| 64 | |
| 65 | } // namespace |