Chromium Code Reviews| Index: webrtc/modules/desktop_capture/screen_drawer_unittest.cc |
| diff --git a/webrtc/modules/desktop_capture/screen_drawer_unittest.cc b/webrtc/modules/desktop_capture/screen_drawer_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d5a652c5dc85e3a121889bb5d5c844190847aa32 |
| --- /dev/null |
| +++ b/webrtc/modules/desktop_capture/screen_drawer_unittest.cc |
| @@ -0,0 +1,55 @@ |
| +/* |
| + * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
| + * |
| + * Use of this source code is governed by a BSD-style license |
| + * that can be found in the LICENSE file in the root of the source |
| + * tree. An additional intellectual property rights grant can be found |
| + * in the file PATENTS. All contributing project authors may |
| + * be found in the AUTHORS file in the root of the source tree. |
| + */ |
| + |
| +// TODO(zijiehe): Implement ScreenDrawerLinux / ScreenDrawerMac. |
|
Sergey Ulanov
2016/08/09 17:43:01
Don't you already have it implemented in this CL?
Hzj_jie
2016/08/11 18:42:04
Should be updated, no, I have not implemented Scre
|
| +#if defined(WEBRTC_WIN) || defined(USE_X11) |
|
Sergey Ulanov
2016/08/09 17:43:01
move this next to the test itself?
Alternatively y
Hzj_jie
2016/08/11 18:42:04
Good point. Done.
|
| + |
| +#include "webrtc/modules/desktop_capture/screen_drawer.h" |
| + |
| +#include <stdint.h> |
| + |
| +#include "testing/gtest/include/gtest/gtest.h" |
| +#include "webrtc/base/random.h" |
| +#include "webrtc/base/timeutils.h" |
| +#include "webrtc/system_wrappers/include/sleep.h" |
| + |
| +namespace webrtc { |
| + |
| +// These are a set of manual test cases, as we do not have an automatical way to |
| +// detect whether a ScreenDrawer on a certain platform works well without |
| +// ScreenCapturer(s). So you may execute these test cases with |
| +// --gtest_also_run_disabled_tests --gtest_filter=ScreenDrawerTest.*. |
| +TEST(ScreenDrawerTest, DISABLED_DrawRectangles) { |
|
Sergey Ulanov
2016/08/09 17:43:01
MANUAL_ prefix is usually used for manual tests.
Hzj_jie
2016/08/11 18:42:04
Done.
Hzj_jie
2016/08/15 00:37:47
DISABLED_ can block gtest from running this test c
|
| + std::unique_ptr<ScreenDrawer> drawer = ScreenDrawer::Create(); |
| + drawer->Clear(); |
| + DesktopRect rect = drawer->DrawableRegion(); |
| + Random random(rtc::TimeMicros()); |
| + for (int i = 0; i < 100; i++) { |
| + // Make sure we at least draw one pixel. |
| + int left = random.Rand(rect.left(), rect.right() - 2); |
| + int top = random.Rand(rect.top(), rect.bottom() - 2); |
| + drawer->DrawRectangle( |
| + DesktopRect::MakeLTRB(left, top, random.Rand(left + 1, rect.right()), |
| + random.Rand(top + 1, rect.bottom())), |
| + random.Rand<uint32_t>()); |
|
Sergey Ulanov
2016/08/09 17:43:01
I think you want to limit the range to [0..2^24)?
Hzj_jie
2016/08/11 18:42:04
I still prefer to use RGBA, though both Windows an
|
| + |
| + if (i == 50) { |
| + SleepMs(10000); |
| + drawer->Clear(); |
| + } |
| + } |
| + |
| + SleepMs(10000); |
| + drawer->Clear(); |
| +} |
| + |
| +} // namespace webrtc |
| + |
| +#endif |
|
Sergey Ulanov
2016/08/09 17:43:01
// defined(WEBRTC_WIN) || defined(USE_X11)
Hzj_jie
2016/08/11 18:42:04
This line has been removed.
|