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

Side by Side Diff: webrtc/media/base/capturemanager_unittest.cc

Issue 1587193006: Move talk/media to webrtc/media (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rename back test to libjingle_media_unittest Created 4 years, 11 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 /* 1 /*
2 * libjingle 2 * Copyright 2012 The WebRTC Project Authors. All rights reserved.
3 * Copyright 2012 Google Inc.
4 * 3 *
5 * Redistribution and use in source and binary forms, with or without 4 * Use of this source code is governed by a BSD-style license
6 * modification, are permitted provided that the following conditions are met: 5 * that can be found in the LICENSE file in the root of the source
7 * 6 * tree. An additional intellectual property rights grant can be found
8 * 1. Redistributions of source code must retain the above copyright notice, 7 * in the file PATENTS. All contributing project authors may
9 * this list of conditions and the following disclaimer. 8 * be found in the AUTHORS file in the root of the source tree.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 9 */
27 10
28 #include "talk/media/base/capturemanager.h" 11 #include "webrtc/media/base/capturemanager.h"
29 12
30 #include "talk/media/base/fakevideocapturer.h"
31 #include "talk/media/base/fakevideorenderer.h"
32 #include "webrtc/base/arraysize.h" 13 #include "webrtc/base/arraysize.h"
33 #include "webrtc/base/gunit.h" 14 #include "webrtc/base/gunit.h"
34 #include "webrtc/base/sigslot.h" 15 #include "webrtc/base/sigslot.h"
16 #include "webrtc/media/base/fakevideocapturer.h"
17 #include "webrtc/media/base/fakevideorenderer.h"
35 18
36 const int kMsCallbackWait = 50; 19 const int kMsCallbackWait = 50;
37 20
38 const int kFps = 30; 21 const int kFps = 30;
39 const cricket::VideoFormatPod kCameraFormats[] = { 22 const cricket::VideoFormatPod kCameraFormats[] = {
40 {640, 480, cricket::VideoFormat::FpsToInterval(kFps), cricket::FOURCC_I420}, 23 {640, 480, cricket::VideoFormat::FpsToInterval(kFps), cricket::FOURCC_I420},
41 {320, 240, cricket::VideoFormat::FpsToInterval(kFps), cricket::FOURCC_I420} 24 {320, 240, cricket::VideoFormat::FpsToInterval(kFps), cricket::FOURCC_I420}
42 }; 25 };
43 26
44 class CaptureManagerTest : public ::testing::Test, public sigslot::has_slots<> { 27 class CaptureManagerTest : public ::testing::Test, public sigslot::has_slots<> {
45 public: 28 public:
46 CaptureManagerTest() 29 CaptureManagerTest()
47 : capture_manager_(), 30 : capture_manager_(),
48 callback_count_(0), 31 callback_count_(0),
49 format_vga_(kCameraFormats[0]), 32 format_vga_(kCameraFormats[0]),
50 format_qvga_(kCameraFormats[1]) { 33 format_qvga_(kCameraFormats[1]) {
51 } 34 }
52 virtual void SetUp() { 35 virtual void SetUp() {
53 PopulateSupportedFormats(); 36 PopulateSupportedFormats();
54 capture_state_ = cricket::CS_STOPPED; 37 capture_state_ = cricket::CS_STOPPED;
55 capture_manager_.SignalCapturerStateChange.connect( 38 capture_manager_.SignalCapturerStateChange.connect(
56 this, 39 this,
57 &CaptureManagerTest::OnCapturerStateChange); 40 &CaptureManagerTest::OnCapturerStateChange);
58 } 41 }
59 void PopulateSupportedFormats() { 42 void PopulateSupportedFormats() {
60 std::vector<cricket::VideoFormat> formats; 43 std::vector<cricket::VideoFormat> formats;
61 for (int i = 0; i < arraysize(kCameraFormats); ++i) { 44 for (uint32_t i = 0; i < arraysize(kCameraFormats); ++i) {
62 formats.push_back(cricket::VideoFormat(kCameraFormats[i])); 45 formats.push_back(cricket::VideoFormat(kCameraFormats[i]));
63 } 46 }
64 video_capturer_.ResetSupportedFormats(formats); 47 video_capturer_.ResetSupportedFormats(formats);
65 } 48 }
66 int NumFramesRendered() { return video_renderer_.num_rendered_frames(); } 49 int NumFramesRendered() { return video_renderer_.num_rendered_frames(); }
67 bool WasRenderedResolution(cricket::VideoFormat format) { 50 bool WasRenderedResolution(cricket::VideoFormat format) {
68 return format.width == video_renderer_.width() && 51 return format.width == video_renderer_.width() &&
69 format.height == video_renderer_.height(); 52 format.height == video_renderer_.height();
70 } 53 }
71 cricket::CaptureState capture_state() { return capture_state_; } 54 cricket::CaptureState capture_state() { return capture_state_; }
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 // Now request restart with qvga. 203 // Now request restart with qvga.
221 EXPECT_TRUE(capture_manager_.RestartVideoCapture( 204 EXPECT_TRUE(capture_manager_.RestartVideoCapture(
222 &video_capturer_, format_vga_, format_qvga_, 205 &video_capturer_, format_vga_, format_qvga_,
223 cricket::CaptureManager::kRequestRestart)); 206 cricket::CaptureManager::kRequestRestart));
224 EXPECT_TRUE(video_capturer_.CaptureFrame()); 207 EXPECT_TRUE(video_capturer_.CaptureFrame());
225 EXPECT_EQ(2, NumFramesRendered()); 208 EXPECT_EQ(2, NumFramesRendered());
226 EXPECT_TRUE(WasRenderedResolution(format_vga_)); 209 EXPECT_TRUE(WasRenderedResolution(format_vga_));
227 EXPECT_TRUE(capture_manager_.StopVideoCapture(&video_capturer_, 210 EXPECT_TRUE(capture_manager_.StopVideoCapture(&video_capturer_,
228 format_qvga_)); 211 format_qvga_));
229 } 212 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698