OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "media/base/factory.h" | 7 #include "media/base/factory.h" |
8 #include "media/base/filter_host.h" | 8 #include "media/base/filter_host.h" |
9 #include "media/base/filters.h" | 9 #include "media/base/filters.h" |
10 #include "media/base/media_format.h" | 10 #include "media/base/media_format.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 p.SetPlaybackRate(1.0f); | 45 p.SetPlaybackRate(1.0f); |
46 PlatformThread::Sleep(static_cast<int>(test_time.InMilliseconds())); | 46 PlatformThread::Sleep(static_cast<int>(test_time.InMilliseconds())); |
47 p.Stop(); | 47 p.Stop(); |
48 // Allow a decent amount of variability here. We expect 15 or 16 frames | 48 // Allow a decent amount of variability here. We expect 15 or 16 frames |
49 // but for now make sure it's within a reasonable range. | 49 // but for now make sure it's within a reasonable range. |
50 int64 num_expected_frames = test_time / config.frame_duration; | 50 int64 num_expected_frames = test_time / config.frame_duration; |
51 EXPECT_GT(test_renderer->unique_frames(), num_expected_frames - 3); | 51 EXPECT_GT(test_renderer->unique_frames(), num_expected_frames - 3); |
52 EXPECT_LT(test_renderer->unique_frames(), num_expected_frames + 3); | 52 EXPECT_LT(test_renderer->unique_frames(), num_expected_frames + 3); |
53 } | 53 } |
54 | 54 |
| 55 TEST(VideoRenderer, SingleVideoFrame) { |
| 56 base::TimeDelta test_time = base::TimeDelta::FromMilliseconds(100); |
| 57 std::string url(""); |
| 58 PipelineImpl p; |
| 59 scoped_refptr<TestVideoRenderer> test_renderer = new TestVideoRenderer(); |
| 60 MockFilterConfig config; |
| 61 config.media_duration = config.frame_duration; |
| 62 scoped_refptr<FilterFactoryCollection> c = new FilterFactoryCollection(); |
| 63 c->AddFactory(MockDataSource::CreateFactory(&config)); |
| 64 c->AddFactory(MockDemuxer::CreateFactory(&config)); |
| 65 c->AddFactory(MockAudioDecoder::CreateFactory(&config)); |
| 66 c->AddFactory(MockAudioRenderer::CreateFactory(&config)); |
| 67 c->AddFactory(MockVideoDecoder::CreateFactory(&config)); |
| 68 c->AddFactory(new InstanceFilterFactory<TestVideoRenderer>(test_renderer)); |
| 69 media::InitializationHelper h; |
| 70 h.Start(&p, c, url); |
| 71 h.TimedWait(base::TimeDelta::FromSeconds(1)); |
| 72 EXPECT_TRUE(p.IsInitialized()); |
| 73 p.SetPlaybackRate(1.0f); |
| 74 PlatformThread::Sleep(static_cast<int>(test_time.InMilliseconds())); |
| 75 p.Stop(); |
| 76 EXPECT_EQ(test_renderer->unique_frames(), 1u); |
| 77 EXPECT_EQ(test_renderer->paint_called(), 1u); |
| 78 } |
OLD | NEW |