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

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: Rebased to b647aca12a884a13c1728118586245399b55fa3d (#11493) Created 4 years, 10 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
« no previous file with comments | « webrtc/media/base/capturemanager.cc ('k') | webrtc/media/base/capturerenderadapter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation 11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution. 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 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. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 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 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 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, 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 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 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28 #include "talk/media/base/capturemanager.h" 28 #include "webrtc/media/base/capturemanager.h"
29 29
30 #include "talk/media/base/fakevideocapturer.h"
31 #include "talk/media/base/fakevideorenderer.h"
32 #include "webrtc/base/arraysize.h" 30 #include "webrtc/base/arraysize.h"
33 #include "webrtc/base/gunit.h" 31 #include "webrtc/base/gunit.h"
34 #include "webrtc/base/sigslot.h" 32 #include "webrtc/base/sigslot.h"
33 #include "webrtc/media/base/fakevideocapturer.h"
34 #include "webrtc/media/base/fakevideorenderer.h"
35 35
36 const int kMsCallbackWait = 50; 36 const int kMsCallbackWait = 50;
37 37
38 const int kFps = 30; 38 const int kFps = 30;
39 const cricket::VideoFormatPod kCameraFormats[] = { 39 const cricket::VideoFormatPod kCameraFormats[] = {
40 {640, 480, cricket::VideoFormat::FpsToInterval(kFps), cricket::FOURCC_I420}, 40 {640, 480, cricket::VideoFormat::FpsToInterval(kFps), cricket::FOURCC_I420},
41 {320, 240, cricket::VideoFormat::FpsToInterval(kFps), cricket::FOURCC_I420} 41 {320, 240, cricket::VideoFormat::FpsToInterval(kFps), cricket::FOURCC_I420}
42 }; 42 };
43 43
44 class CaptureManagerTest : public ::testing::Test, public sigslot::has_slots<> { 44 class CaptureManagerTest : public ::testing::Test, public sigslot::has_slots<> {
45 public: 45 public:
46 CaptureManagerTest() 46 CaptureManagerTest()
47 : capture_manager_(), 47 : capture_manager_(),
48 callback_count_(0), 48 callback_count_(0),
49 format_vga_(kCameraFormats[0]), 49 format_vga_(kCameraFormats[0]),
50 format_qvga_(kCameraFormats[1]) { 50 format_qvga_(kCameraFormats[1]) {
51 } 51 }
52 virtual void SetUp() { 52 virtual void SetUp() {
53 PopulateSupportedFormats(); 53 PopulateSupportedFormats();
54 capture_state_ = cricket::CS_STOPPED; 54 capture_state_ = cricket::CS_STOPPED;
55 capture_manager_.SignalCapturerStateChange.connect( 55 capture_manager_.SignalCapturerStateChange.connect(
56 this, 56 this,
57 &CaptureManagerTest::OnCapturerStateChange); 57 &CaptureManagerTest::OnCapturerStateChange);
58 } 58 }
59 void PopulateSupportedFormats() { 59 void PopulateSupportedFormats() {
60 std::vector<cricket::VideoFormat> formats; 60 std::vector<cricket::VideoFormat> formats;
61 for (int i = 0; i < arraysize(kCameraFormats); ++i) { 61 for (uint32_t i = 0; i < arraysize(kCameraFormats); ++i) {
62 formats.push_back(cricket::VideoFormat(kCameraFormats[i])); 62 formats.push_back(cricket::VideoFormat(kCameraFormats[i]));
63 } 63 }
64 video_capturer_.ResetSupportedFormats(formats); 64 video_capturer_.ResetSupportedFormats(formats);
65 } 65 }
66 int NumFramesRendered() { return video_renderer_.num_rendered_frames(); } 66 int NumFramesRendered() { return video_renderer_.num_rendered_frames(); }
67 bool WasRenderedResolution(cricket::VideoFormat format) { 67 bool WasRenderedResolution(cricket::VideoFormat format) {
68 return format.width == video_renderer_.width() && 68 return format.width == video_renderer_.width() &&
69 format.height == video_renderer_.height(); 69 format.height == video_renderer_.height();
70 } 70 }
71 cricket::CaptureState capture_state() { return capture_state_; } 71 cricket::CaptureState capture_state() { return capture_state_; }
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 // Now request restart with qvga. 208 // Now request restart with qvga.
209 EXPECT_TRUE(capture_manager_.RestartVideoCapture( 209 EXPECT_TRUE(capture_manager_.RestartVideoCapture(
210 &video_capturer_, format_vga_, format_qvga_, 210 &video_capturer_, format_vga_, format_qvga_,
211 cricket::CaptureManager::kRequestRestart)); 211 cricket::CaptureManager::kRequestRestart));
212 EXPECT_TRUE(video_capturer_.CaptureFrame()); 212 EXPECT_TRUE(video_capturer_.CaptureFrame());
213 EXPECT_EQ(2, NumFramesRendered()); 213 EXPECT_EQ(2, NumFramesRendered());
214 EXPECT_TRUE(WasRenderedResolution(format_vga_)); 214 EXPECT_TRUE(WasRenderedResolution(format_vga_));
215 EXPECT_TRUE(capture_manager_.StopVideoCapture(&video_capturer_, 215 EXPECT_TRUE(capture_manager_.StopVideoCapture(&video_capturer_,
216 format_qvga_)); 216 format_qvga_));
217 } 217 }
OLDNEW
« no previous file with comments | « webrtc/media/base/capturemanager.cc ('k') | webrtc/media/base/capturerenderadapter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698