| OLD | NEW | 
|    1 // Copyright 2016 The Chromium Authors. All rights reserved. |    1 // Copyright 2016 The Chromium Authors. All rights reserved. | 
|    2 // Use of this source code is governed by a BSD-style license that can be |    2 // Use of this source code is governed by a BSD-style license that can be | 
|    3 // found in the LICENSE file. |    3 // found in the LICENSE file. | 
|    4  |    4  | 
|    5 #include "modules/webaudio/BaseAudioContext.h" |    5 #include "modules/webaudio/BaseAudioContext.h" | 
|    6  |    6  | 
|    7 #include "bindings/core/v8/V8BindingForCore.h" |    7 #include "bindings/core/v8/V8BindingForCore.h" | 
|    8 #include "core/dom/Document.h" |    8 #include "core/dom/Document.h" | 
|    9 #include "core/dom/DocumentUserGestureToken.h" |    9 #include "core/dom/DocumentUserGestureToken.h" | 
|   10 #include "core/frame/FrameOwner.h" |   10 #include "core/frame/FrameOwner.h" | 
|   11 #include "core/frame/FrameTypes.h" |   11 #include "core/frame/FrameTypes.h" | 
|   12 #include "core/frame/FrameView.h" |   12 #include "core/frame/FrameView.h" | 
|   13 #include "core/frame/Settings.h" |   13 #include "core/frame/Settings.h" | 
|   14 #include "core/loader/DocumentLoader.h" |   14 #include "core/loader/DocumentLoader.h" | 
|   15 #include "core/loader/EmptyClients.h" |   15 #include "core/loader/EmptyClients.h" | 
|   16 #include "core/testing/DummyPageHolder.h" |   16 #include "core/testing/DummyPageHolder.h" | 
|   17 #include "modules/webaudio/AudioContextOptions.h" |   17 #include "modules/webaudio/AudioContextOptions.h" | 
|   18 #include "platform/UserGestureIndicator.h" |   18 #include "platform/UserGestureIndicator.h" | 
|   19 #include "platform/testing/HistogramTester.h" |   19 #include "platform/testing/HistogramTester.h" | 
|   20 #include "platform/testing/TestingPlatformSupport.h" |   20 #include "platform/testing/TestingPlatformSupport.h" | 
 |   21 #include "platform/wtf/PtrUtil.h" | 
|   21 #include "public/platform/WebAudioDevice.h" |   22 #include "public/platform/WebAudioDevice.h" | 
|   22 #include "public/platform/WebAudioLatencyHint.h" |   23 #include "public/platform/WebAudioLatencyHint.h" | 
|   23 #include "testing/gtest/include/gtest/gtest.h" |   24 #include "testing/gtest/include/gtest/gtest.h" | 
|   24  |   25  | 
|   25 namespace blink { |   26 namespace blink { | 
|   26  |   27  | 
|   27 namespace { |   28 namespace { | 
|   28  |   29  | 
|   29 const char* const kCrossOriginMetric = "WebAudio.Autoplay.CrossOrigin"; |   30 const char* const kCrossOriginMetric = "WebAudio.Autoplay.CrossOrigin"; | 
|   30  |   31  | 
| (...skipping 28 matching lines...) Expand all  Loading... | 
|   59   double SampleRate() override { return sample_rate_; } |   60   double SampleRate() override { return sample_rate_; } | 
|   60   int FramesPerBuffer() override { return frames_per_buffer_; } |   61   int FramesPerBuffer() override { return frames_per_buffer_; } | 
|   61  |   62  | 
|   62  private: |   63  private: | 
|   63   double sample_rate_; |   64   double sample_rate_; | 
|   64   int frames_per_buffer_; |   65   int frames_per_buffer_; | 
|   65 }; |   66 }; | 
|   66  |   67  | 
|   67 class BaseAudioContextTestPlatform : public TestingPlatformSupport { |   68 class BaseAudioContextTestPlatform : public TestingPlatformSupport { | 
|   68  public: |   69  public: | 
|   69   WebAudioDevice* CreateAudioDevice(unsigned number_of_input_channels, |   70   std::unique_ptr<WebAudioDevice> CreateAudioDevice( | 
|   70                                     unsigned number_of_channels, |   71       unsigned number_of_input_channels, | 
|   71                                     const WebAudioLatencyHint& latency_hint, |   72       unsigned number_of_channels, | 
|   72                                     WebAudioDevice::RenderCallback*, |   73       const WebAudioLatencyHint& latency_hint, | 
|   73                                     const WebString& device_id, |   74       WebAudioDevice::RenderCallback*, | 
|   74                                     const WebSecurityOrigin&) override { |   75       const WebString& device_id, | 
|   75     return new MockWebAudioDevice(AudioHardwareSampleRate(), |   76       const WebSecurityOrigin&) override { | 
|   76                                   AudioHardwareBufferSize()); |   77     return WTF::MakeUnique<MockWebAudioDevice>(AudioHardwareSampleRate(), | 
 |   78                                                AudioHardwareBufferSize()); | 
|   77   } |   79   } | 
|   78  |   80  | 
|   79   double AudioHardwareSampleRate() override { return 44100; } |   81   double AudioHardwareSampleRate() override { return 44100; } | 
|   80   size_t AudioHardwareBufferSize() override { return 128; } |   82   size_t AudioHardwareBufferSize() override { return 128; } | 
|   81 }; |   83 }; | 
|   82  |   84  | 
|   83 }  // anonymous namespace |   85 }  // anonymous namespace | 
|   84  |   86  | 
|   85 class BaseAudioContextTest : public ::testing::Test { |   87 class BaseAudioContextTest : public ::testing::Test { | 
|   86  protected: |   88  protected: | 
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  284   audio_context->resumeContext(GetScriptStateFrom(ChildDocument())); |  286   audio_context->resumeContext(GetScriptStateFrom(ChildDocument())); | 
|  285   RejectPendingResolvers(audio_context); |  287   RejectPendingResolvers(audio_context); | 
|  286   RecordAutoplayStatus(audio_context); |  288   RecordAutoplayStatus(audio_context); | 
|  287  |  289  | 
|  288   histogram_tester.ExpectBucketCount( |  290   histogram_tester.ExpectBucketCount( | 
|  289       kCrossOriginMetric, AutoplayStatus::kAutoplayStatusSucceeded, 1); |  291       kCrossOriginMetric, AutoplayStatus::kAutoplayStatusSucceeded, 1); | 
|  290   histogram_tester.ExpectTotalCount(kCrossOriginMetric, 1); |  292   histogram_tester.ExpectTotalCount(kCrossOriginMetric, 1); | 
|  291 } |  293 } | 
|  292  |  294  | 
|  293 }  // namespace blink |  295 }  // namespace blink | 
| OLD | NEW |