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

Side by Side Diff: media/base/download_rate_monitor_unittest.cc

Issue 8661002: Fire CanPlayThrough immediately for local and streaming media files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "media/base/download_rate_monitor.h" 5 #include "media/base/download_rate_monitor.h"
6 6
7 #include "testing/gmock/include/gmock/gmock.h" 7 #include "testing/gmock/include/gmock/gmock.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 using ::testing::Mock; 10 using ::testing::Mock;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 125
126 monitor_.set_loaded(true); 126 monitor_.set_loaded(true);
127 127
128 // Simulate no data downloaded (source is already loaded). 128 // Simulate no data downloaded (source is already loaded).
129 EXPECT_CALL(*this, CanPlayThrough()); 129 EXPECT_CALL(*this, CanPlayThrough());
130 monitor_.Start(base::Bind(&DownloadRateMonitorTest::CanPlayThrough, 130 monitor_.Start(base::Bind(&DownloadRateMonitorTest::CanPlayThrough,
131 base::Unretained(this)), media_bitrate); 131 base::Unretained(this)), media_bitrate);
132 SimulateNetwork(1, 0, 0, 1000, 10); 132 SimulateNetwork(1, 0, 0, 1000, 10);
133 } 133 }
134 134
135 // Test the MediaStream object, e.g. video capture.
136 TEST_F(DownloadRateMonitorTest, IsMediaStream) {
137 static const int media_bitrate = 1024 * 1024 * 8;
138
139 monitor_.set_media_stream(true);
140
141 // Simulate no data downloaded (as if source is a local webcam).
142 EXPECT_CALL(*this, CanPlayThrough());
143 monitor_.Start(base::Bind(&DownloadRateMonitorTest::CanPlayThrough,
144 base::Unretained(this)), media_bitrate);
145 SimulateNetwork(1, 0, 0, 1000, 10);
146 }
147
135 TEST_F(DownloadRateMonitorTest, VeryFastDownloadRate) { 148 TEST_F(DownloadRateMonitorTest, VeryFastDownloadRate) {
136 static const int media_bitrate = 1024 * 1024 * 8; 149 static const int media_bitrate = 1024 * 1024 * 8;
137 150
138 // Simulate downloading half the video very quickly in one chunk. 151 // Simulate downloading half the video very quickly in one chunk.
139 monitor_.Start(base::Bind(&DownloadRateMonitorTest::CanPlayThrough, 152 monitor_.Start(base::Bind(&DownloadRateMonitorTest::CanPlayThrough,
140 base::Unretained(this)), media_bitrate); 153 base::Unretained(this)), media_bitrate);
141 EXPECT_CALL(*this, CanPlayThrough()); 154 EXPECT_CALL(*this, CanPlayThrough());
142 SimulateNetwork(1, 0, kMediaSizeInBytes / 2, 10, 1); 155 SimulateNetwork(1, 0, kMediaSizeInBytes / 2, 10, 1);
143 } 156 }
144 157
145 TEST_F(DownloadRateMonitorTest, DownloadEntireVideo) { 158 TEST_F(DownloadRateMonitorTest, DownloadEntireVideo) {
146 static const int seconds_of_data = 20; 159 static const int seconds_of_data = 20;
147 static const int media_bitrate = kMediaSizeInBytes * 8 / seconds_of_data; 160 static const int media_bitrate = kMediaSizeInBytes * 8 / seconds_of_data;
148 161
149 // Simulate downloading entire video at half the bitrate of the video. 162 // Simulate downloading entire video at half the bitrate of the video.
150 monitor_.Start(base::Bind(&DownloadRateMonitorTest::CanPlayThrough, 163 monitor_.Start(base::Bind(&DownloadRateMonitorTest::CanPlayThrough,
151 base::Unretained(this)), media_bitrate); 164 base::Unretained(this)), media_bitrate);
152 EXPECT_CALL(*this, CanPlayThrough()); 165 EXPECT_CALL(*this, CanPlayThrough());
153 SimulateNetwork(1, 0, media_bitrate / 8 / 2, 1000, seconds_of_data * 2); 166 SimulateNetwork(1, 0, media_bitrate / 8 / 2, 1000, seconds_of_data * 2);
154 } 167 }
155 168
156 } // namespace media 169 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698