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

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/AudioContextTest.cpp

Issue 2867693004: Snapshot of all changes to get jumbo in blink and content.
Patch Set: Rebased again Created 3 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/AudioContext.h" 5 #include "modules/webaudio/AudioContext.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/testing/DummyPageHolder.h" 8 #include "core/testing/DummyPageHolder.h"
9 #include "platform/testing/TestingPlatformSupport.h" 9 #include "platform/testing/TestingPlatformSupport.h"
10 #include "platform/wtf/PtrUtil.h" 10 #include "platform/wtf/PtrUtil.h"
11 #include "public/platform/WebAudioDevice.h" 11 #include "public/platform/WebAudioDevice.h"
12 #include "public/platform/WebAudioLatencyHint.h" 12 #include "public/platform/WebAudioLatencyHint.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 namespace blink { 15 namespace blink {
16 16
17 namespace { 17 namespace {
18 18
19 class MockWebAudioDevice : public WebAudioDevice { 19 class MockWebAudioDeviceForAudioContext : public WebAudioDevice {
20 public: 20 public:
21 explicit MockWebAudioDevice(double sample_rate, int frames_per_buffer) 21 explicit MockWebAudioDeviceForAudioContext(double sample_rate,
22 int frames_per_buffer)
22 : sample_rate_(sample_rate), frames_per_buffer_(frames_per_buffer) {} 23 : sample_rate_(sample_rate), frames_per_buffer_(frames_per_buffer) {}
23 ~MockWebAudioDevice() override = default; 24 ~MockWebAudioDeviceForAudioContext() override = default;
24 25
25 void Start() override {} 26 void Start() override {}
26 void Stop() override {} 27 void Stop() override {}
27 double SampleRate() override { return sample_rate_; } 28 double SampleRate() override { return sample_rate_; }
28 int FramesPerBuffer() override { return frames_per_buffer_; } 29 int FramesPerBuffer() override { return frames_per_buffer_; }
29 30
30 private: 31 private:
31 double sample_rate_; 32 double sample_rate_;
32 int frames_per_buffer_; 33 int frames_per_buffer_;
33 }; 34 };
(...skipping 25 matching lines...) Expand all
59 buffer_size = 60 buffer_size =
60 clampTo(latency_hint.Seconds() * AudioHardwareSampleRate(), 61 clampTo(latency_hint.Seconds() * AudioHardwareSampleRate(),
61 static_cast<double>(AudioHardwareBufferSize()), 62 static_cast<double>(AudioHardwareBufferSize()),
62 static_cast<double>(playback_size)); 63 static_cast<double>(playback_size));
63 break; 64 break;
64 default: 65 default:
65 NOTREACHED(); 66 NOTREACHED();
66 break; 67 break;
67 } 68 }
68 69
69 return WTF::MakeUnique<MockWebAudioDevice>(AudioHardwareSampleRate(), 70 return WTF::MakeUnique<MockWebAudioDeviceForAudioContext>(
70 buffer_size); 71 AudioHardwareSampleRate(), buffer_size);
71 } 72 }
72 73
73 double AudioHardwareSampleRate() override { return 44100; } 74 double AudioHardwareSampleRate() override { return 44100; }
74 size_t AudioHardwareBufferSize() override { return 128; } 75 size_t AudioHardwareBufferSize() override { return 128; }
75 }; 76 };
76 77
77 } // anonymous namespace 78 } // anonymous namespace
78 79
79 class AudioContextTest : public ::testing::Test { 80 class AudioContextTest : public ::testing::Test {
80 protected: 81 protected:
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 exact_too_big_options.setLatencyHint( 137 exact_too_big_options.setLatencyHint(
137 AudioContextLatencyCategoryOrDouble::fromDouble( 138 AudioContextLatencyCategoryOrDouble::fromDouble(
138 playback_context->baseLatency() * 2)); 139 playback_context->baseLatency() * 2));
139 AudioContext* exact_too_big_context = AudioContext::Create( 140 AudioContext* exact_too_big_context = AudioContext::Create(
140 GetDocument(), exact_too_big_options, ASSERT_NO_EXCEPTION); 141 GetDocument(), exact_too_big_options, ASSERT_NO_EXCEPTION);
141 EXPECT_EQ(exact_too_big_context->baseLatency(), 142 EXPECT_EQ(exact_too_big_context->baseLatency(),
142 playback_context->baseLatency()); 143 playback_context->baseLatency());
143 } 144 }
144 145
145 } // namespace blink 146 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698