diff options
author | Yves Gerey <yvesg@webrtc.org> | 2018-06-19 15:03:05 +0200 |
---|---|---|
committer | Yves Gerey <yvesg@webrtc.org> | 2018-06-19 14:00:39 +0000 |
commit | 665174fdbb4e0540eccb27cf7412348f1b65534c (patch) | |
tree | 34a9eb770e6de54c282f62ad0b65d2cd69c917f6 /modules/video_capture/test | |
parent | b602123a5aae1a9f0b6b581e611acf44eb525c08 (diff) | |
download | webrtc-665174fdbb4e0540eccb27cf7412348f1b65534c.tar.gz |
Reformat the WebRTC code base
Running clang-format with chromium's style guide.
The goal is n-fold:
* providing consistency and readability (that's what code guidelines are for)
* preventing noise with presubmit checks and git cl format
* building on the previous point: making it easier to automatically fix format issues
* you name it
Please consider using git-hyper-blame to ignore this commit.
Bug: webrtc:9340
Change-Id: I694567c4cdf8cee2860958cfe82bfaf25848bb87
Reviewed-on: https://webrtc-review.googlesource.com/81185
Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23660}
Diffstat (limited to 'modules/video_capture/test')
-rw-r--r-- | modules/video_capture/test/video_capture_unittest.cc | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/modules/video_capture/test/video_capture_unittest.cc b/modules/video_capture/test/video_capture_unittest.cc index 1c6d06480d..aed299c012 100644 --- a/modules/video_capture/test/video_capture_unittest.cc +++ b/modules/video_capture/test/video_capture_unittest.cc @@ -32,25 +32,24 @@ using webrtc::VideoCaptureCapability; using webrtc::VideoCaptureFactory; using webrtc::VideoCaptureModule; - -#define WAIT_(ex, timeout, res) \ - do { \ - res = (ex); \ - int64_t start = rtc::TimeMillis(); \ +#define WAIT_(ex, timeout, res) \ + do { \ + res = (ex); \ + int64_t start = rtc::TimeMillis(); \ while (!res && rtc::TimeMillis() < start + timeout) { \ - SleepMs(5); \ - res = (ex); \ - } \ + SleepMs(5); \ + res = (ex); \ + } \ } while (0) #define EXPECT_TRUE_WAIT(ex, timeout) \ - do { \ - bool res; \ - WAIT_(ex, timeout, res); \ - if (!res) EXPECT_TRUE(ex); \ + do { \ + bool res; \ + WAIT_(ex, timeout, res); \ + if (!res) \ + EXPECT_TRUE(ex); \ } while (0) - static const int kTimeOut = 5000; static const int kTestHeight = 288; static const int kTestWidth = 352; @@ -59,8 +58,8 @@ static const int kTestFramerate = 30; class TestVideoCaptureCallback : public rtc::VideoSinkInterface<webrtc::VideoFrame> { public: - TestVideoCaptureCallback() : - last_render_time_ms_(0), + TestVideoCaptureCallback() + : last_render_time_ms_(0), incoming_frames_(0), timing_warnings_(0), rotate_frame_(webrtc::kVideoRotation_0) {} @@ -85,16 +84,15 @@ class TestVideoCaptureCallback EXPECT_EQ(rotate_frame_, videoFrame.rotation()); #endif // RenderTimstamp should be the time now. - EXPECT_TRUE( - videoFrame.render_time_ms() >= rtc::TimeMillis()-30 && - videoFrame.render_time_ms() <= rtc::TimeMillis()); + EXPECT_TRUE(videoFrame.render_time_ms() >= rtc::TimeMillis() - 30 && + videoFrame.render_time_ms() <= rtc::TimeMillis()); if ((videoFrame.render_time_ms() > - last_render_time_ms_ + (1000 * 1.1) / capability_.maxFPS && - last_render_time_ms_ > 0) || + last_render_time_ms_ + (1000 * 1.1) / capability_.maxFPS && + last_render_time_ms_ > 0) || (videoFrame.render_time_ms() < - last_render_time_ms_ + (1000 * 0.9) / capability_.maxFPS && - last_render_time_ms_ > 0)) { + last_render_time_ms_ + (1000 * 0.9) / capability_.maxFPS && + last_render_time_ms_ > 0)) { timing_warnings_++; } @@ -105,7 +103,7 @@ class TestVideoCaptureCallback void SetExpectedCapability(VideoCaptureCapability capability) { rtc::CritScope cs(&capture_cs_); - capability_= capability; + capability_ = capability; incoming_frames_ = 0; last_render_time_ms_ = 0; } @@ -161,8 +159,8 @@ class VideoCaptureTest : public testing::Test { char device_name[256]; char unique_name[256]; - EXPECT_EQ(0, device_info_->GetDeviceName( - device, device_name, 256, unique_name, 256)); + EXPECT_EQ(0, device_info_->GetDeviceName(device, device_name, 256, + unique_name, 256)); rtc::scoped_refptr<VideoCaptureModule> module( VideoCaptureFactory::Create(unique_name)); @@ -251,8 +249,8 @@ TEST_F(VideoCaptureTest, MAYBE_Capabilities) { OpenVideoCaptureDevice(0, &capture_observer)); ASSERT_TRUE(module.get() != NULL); - int number_of_capabilities = device_info_->NumberOfCapabilities( - module->CurrentDeviceName()); + int number_of_capabilities = + device_info_->NumberOfCapabilities(module->CurrentDeviceName()); EXPECT_GT(number_of_capabilities, 0); // Key is <width>x<height>, value is vector of maxFPS values at that // resolution. @@ -293,8 +291,7 @@ TEST_F(VideoCaptureTest, MAYBE_Capabilities) { EXPECT_GT(frame_rates_by_resolution.size(), 1U); for (FrameRatesByResolution::const_iterator it = frame_rates_by_resolution.begin(); - it != frame_rates_by_resolution.end(); - ++it) { + it != frame_rates_by_resolution.end(); ++it) { EXPECT_GT(it->second.size(), 1U) << it->first; } #endif // WEBRTC_ANDROID @@ -328,7 +325,6 @@ TEST_F(VideoCaptureTest, DISABLED_TestTwoCameras) { OpenVideoCaptureDevice(1, &capture_observer2)); ASSERT_TRUE(module1.get() != NULL); - VideoCaptureCapability capability2; #ifndef WEBRTC_MAC device_info_->GetCapability(module2->CurrentDeviceName(), 0, capability2); @@ -378,8 +374,7 @@ class VideoCaptureExternalTest : public testing::Test { capture_module_->RegisterCaptureDataCallback(&capture_callback_); } - void TearDown() { - } + void TearDown() {} webrtc::VideoCaptureExternal* capture_input_interface_; rtc::scoped_refptr<VideoCaptureModule> capture_module_; @@ -393,8 +388,9 @@ TEST_F(VideoCaptureExternalTest, TestExternalCapture) { webrtc::VideoType::kI420, test_frame_->width(), test_frame_->height()); std::unique_ptr<uint8_t[]> test_buffer(new uint8_t[length]); webrtc::ExtractBuffer(*test_frame_, length, test_buffer.get()); - EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(), - length, capture_callback_.capability(), 0)); + EXPECT_EQ(0, + capture_input_interface_->IncomingFrame( + test_buffer.get(), length, capture_callback_.capability(), 0)); EXPECT_TRUE(capture_callback_.CompareLastFrame(*test_frame_)); } @@ -404,18 +400,22 @@ TEST_F(VideoCaptureExternalTest, Rotation) { webrtc::VideoType::kI420, test_frame_->width(), test_frame_->height()); std::unique_ptr<uint8_t[]> test_buffer(new uint8_t[length]); webrtc::ExtractBuffer(*test_frame_, length, test_buffer.get()); - EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(), - length, capture_callback_.capability(), 0)); + EXPECT_EQ(0, + capture_input_interface_->IncomingFrame( + test_buffer.get(), length, capture_callback_.capability(), 0)); EXPECT_EQ(0, capture_module_->SetCaptureRotation(webrtc::kVideoRotation_90)); capture_callback_.SetExpectedCaptureRotation(webrtc::kVideoRotation_90); - EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(), - length, capture_callback_.capability(), 0)); + EXPECT_EQ(0, + capture_input_interface_->IncomingFrame( + test_buffer.get(), length, capture_callback_.capability(), 0)); EXPECT_EQ(0, capture_module_->SetCaptureRotation(webrtc::kVideoRotation_180)); capture_callback_.SetExpectedCaptureRotation(webrtc::kVideoRotation_180); - EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(), - length, capture_callback_.capability(), 0)); + EXPECT_EQ(0, + capture_input_interface_->IncomingFrame( + test_buffer.get(), length, capture_callback_.capability(), 0)); EXPECT_EQ(0, capture_module_->SetCaptureRotation(webrtc::kVideoRotation_270)); capture_callback_.SetExpectedCaptureRotation(webrtc::kVideoRotation_270); - EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(), - length, capture_callback_.capability(), 0)); + EXPECT_EQ(0, + capture_input_interface_->IncomingFrame( + test_buffer.get(), length, capture_callback_.capability(), 0)); } |