| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/media/capture/web_contents_video_capture_device.h" | 5 #include "content/browser/media/capture/web_contents_video_capture_device.h" |
| 6 | 6 |
| 7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
| 8 #include "base/debug/debugger.h" | 8 #include "base/debug/debugger.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/test/test_timeouts.h" | 10 #include "base/test/test_timeouts.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 quit_closure.Run(); | 57 quit_closure.Run(); |
| 58 FAIL() << "Deadline exceeded while waiting, quitting"; | 58 FAIL() << "Deadline exceeded while waiting, quitting"; |
| 59 } else { | 59 } else { |
| 60 LOG(WARNING) << "Deadline exceeded; test would fail if debugger weren't " | 60 LOG(WARNING) << "Deadline exceeded; test would fail if debugger weren't " |
| 61 << "attached."; | 61 << "attached."; |
| 62 } | 62 } |
| 63 } | 63 } |
| 64 | 64 |
| 65 void RunCurrentLoopWithDeadline() { | 65 void RunCurrentLoopWithDeadline() { |
| 66 base::Timer deadline(false, false); | 66 base::Timer deadline(false, false); |
| 67 deadline.Start(FROM_HERE, TestTimeouts::action_max_timeout(), base::Bind( | 67 deadline.Start( |
| 68 &DeadlineExceeded, base::MessageLoop::current()->QuitClosure())); | 68 FROM_HERE, TestTimeouts::action_max_timeout(), |
| 69 base::Bind(&DeadlineExceeded, |
| 70 base::MessageLoop::current()->QuitWhenIdleClosure())); |
| 69 base::MessageLoop::current()->Run(); | 71 base::MessageLoop::current()->Run(); |
| 70 deadline.Stop(); | 72 deadline.Stop(); |
| 71 } | 73 } |
| 72 | 74 |
| 73 SkColor ConvertRgbToYuv(SkColor rgb) { | 75 SkColor ConvertRgbToYuv(SkColor rgb) { |
| 74 uint8 yuv[3]; | 76 uint8 yuv[3]; |
| 75 media::ConvertRGB32ToYUV(reinterpret_cast<uint8*>(&rgb), | 77 media::ConvertRGB32ToYUV(reinterpret_cast<uint8*>(&rgb), |
| 76 yuv, yuv + 1, yuv + 2, 1, 1, 1, 1, 1); | 78 yuv, yuv + 1, yuv + 2, 1, 1, 1, 1, 1); |
| 77 return SkColorSetRGB(yuv[0], yuv[1], yuv[2]); | 79 return SkColorSetRGB(yuv[0], yuv[1], yuv[2]); |
| 78 } | 80 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 } | 136 } |
| 135 | 137 |
| 136 bool CanUseFrameSubscriber() { | 138 bool CanUseFrameSubscriber() { |
| 137 base::AutoLock guard(lock_); | 139 base::AutoLock guard(lock_); |
| 138 return use_frame_subscriber_; | 140 return use_frame_subscriber_; |
| 139 } | 141 } |
| 140 | 142 |
| 141 void WaitForNextCopy() { | 143 void WaitForNextCopy() { |
| 142 { | 144 { |
| 143 base::AutoLock guard(lock_); | 145 base::AutoLock guard(lock_); |
| 144 copy_done_ = base::MessageLoop::current()->QuitClosure(); | 146 copy_done_ = base::MessageLoop::current()->QuitWhenIdleClosure(); |
| 145 } | 147 } |
| 146 | 148 |
| 147 RunCurrentLoopWithDeadline(); | 149 RunCurrentLoopWithDeadline(); |
| 148 } | 150 } |
| 149 | 151 |
| 150 private: | 152 private: |
| 151 base::Lock lock_; // Guards changes to all members. | 153 base::Lock lock_; // Guards changes to all members. |
| 152 SkColor color_; | 154 SkColor color_; |
| 153 gfx::Size copy_result_size_; | 155 gfx::Size copy_result_size_; |
| 154 bool can_copy_to_video_frame_; | 156 bool can_copy_to_video_frame_; |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 | 467 |
| 466 virtual ~StubClientObserver() {} | 468 virtual ~StubClientObserver() {} |
| 467 | 469 |
| 468 scoped_ptr<media::VideoCaptureDevice::Client> PassClient() { | 470 scoped_ptr<media::VideoCaptureDevice::Client> PassClient() { |
| 469 return client_.Pass(); | 471 return client_.Pass(); |
| 470 } | 472 } |
| 471 | 473 |
| 472 void QuitIfConditionsMet(SkColor color, const gfx::Size& size) { | 474 void QuitIfConditionsMet(SkColor color, const gfx::Size& size) { |
| 473 base::AutoLock guard(lock_); | 475 base::AutoLock guard(lock_); |
| 474 if (error_encountered_) | 476 if (error_encountered_) |
| 475 base::MessageLoop::current()->Quit(); | 477 base::MessageLoop::current()->QuitWhenIdle(); |
| 476 else if (wait_color_yuv_ == color && wait_size_.IsEmpty()) | 478 else if (wait_color_yuv_ == color && wait_size_.IsEmpty()) |
| 477 base::MessageLoop::current()->Quit(); | 479 base::MessageLoop::current()->QuitWhenIdle(); |
| 478 else if (wait_color_yuv_ == color && wait_size_ == size) | 480 else if (wait_color_yuv_ == color && wait_size_ == size) |
| 479 base::MessageLoop::current()->Quit(); | 481 base::MessageLoop::current()->QuitWhenIdle(); |
| 480 } | 482 } |
| 481 | 483 |
| 482 // Run the current loop until a frame is delivered with the |expected_color| | 484 // Run the current loop until a frame is delivered with the |expected_color| |
| 483 // and any non-empty frame size. | 485 // and any non-empty frame size. |
| 484 void WaitForNextColor(SkColor expected_color) { | 486 void WaitForNextColor(SkColor expected_color) { |
| 485 WaitForNextColorAndFrameSize(expected_color, gfx::Size()); | 487 WaitForNextColorAndFrameSize(expected_color, gfx::Size()); |
| 486 } | 488 } |
| 487 | 489 |
| 488 // Run the current loop until a frame is delivered with the |expected_color| | 490 // Run the current loop until a frame is delivered with the |expected_color| |
| 489 // and is of the |expected_size|. | 491 // and is of the |expected_size|. |
| (...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1133 policies[i], gfx::Size(1000, 1000), gfx::Size(1000, 1000)); | 1135 policies[i], gfx::Size(1000, 1000), gfx::Size(1000, 1000)); |
| 1134 RunTestForPreferredSize( | 1136 RunTestForPreferredSize( |
| 1135 policies[i], gfx::Size(1600, 1000), gfx::Size(1600, 1000)); | 1137 policies[i], gfx::Size(1600, 1000), gfx::Size(1600, 1000)); |
| 1136 RunTestForPreferredSize( | 1138 RunTestForPreferredSize( |
| 1137 policies[i], gfx::Size(837, 999), gfx::Size(837, 999)); | 1139 policies[i], gfx::Size(837, 999), gfx::Size(837, 999)); |
| 1138 } | 1140 } |
| 1139 } | 1141 } |
| 1140 | 1142 |
| 1141 } // namespace | 1143 } // namespace |
| 1142 } // namespace content | 1144 } // namespace content |
| OLD | NEW |