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

Side by Side Diff: remoting/host/capture_scheduler_unittest.cc

Issue 12803008: Add unit tests for sub-components of CaptureScheduler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "remoting/host/capture_scheduler.h"
6 #include "testing/gtest/include/gtest/gtest.h"
7
8 namespace remoting {
9
10 static const int kTestInputs[] = { 100, 50, 30, 20, 10, 30, 60, 80 };
11
12 TEST(CaptureSchedulerTest, SingleSampleSameTimes) {
13 const int kTestResults[][arraysize(kTestInputs)] = {
14 { 400, 200, 120, 80, 50, 120, 240, 320 }, // One core.
15 { 200, 100, 60, 50, 50, 60, 120, 160 }, // Two cores.
16 { 100, 50, 50, 50, 50, 50, 60, 80 }, // Four cores.
17 { 50, 50, 50, 50, 50, 50, 50, 50 } // Eight cores.
18 };
19
20 for (size_t i = 0; i < arraysize(kTestResults); ++i) {
21 for (size_t j = 0; j < arraysize(kTestInputs); ++j) {
22 CaptureScheduler scheduler;
23 scheduler.SetNumOfProcessorsForTest(1 << i);
24 scheduler.RecordCaptureTime(
25 base::TimeDelta::FromMilliseconds(kTestInputs[j]));
26 scheduler.RecordEncodeTime(
27 base::TimeDelta::FromMilliseconds(kTestInputs[j]));
28 EXPECT_EQ(kTestResults[i][j],
29 scheduler.NextCaptureDelay().InMilliseconds());
30 }
31 }
32 }
33
34 TEST(CaptureSchedulerTest, SingleSampleDifferentTimes) {
35 const int kTestResults[][arraysize(kTestInputs)] = {
36 { 360, 220, 120, 60, 60, 120, 220, 360 }, // One core.
37 { 180, 110, 60, 50, 50, 60, 110, 180 }, // Two cores.
38 { 90, 55, 50, 50, 50, 50, 55, 90 }, // Four cores.
39 { 50, 50, 50, 50, 50, 50, 50, 50 } // Eight cores.
40 };
41
42 for (size_t i = 0; i < arraysize(kTestResults); ++i) {
43 for (size_t j = 0; j < arraysize(kTestInputs); ++j) {
44 CaptureScheduler scheduler;
45 scheduler.SetNumOfProcessorsForTest(1 << i);
46 scheduler.RecordCaptureTime(
47 base::TimeDelta::FromMilliseconds(kTestInputs[j]));
48 scheduler.RecordEncodeTime(
49 base::TimeDelta::FromMilliseconds(
50 kTestInputs[arraysize(kTestInputs) - 1 - j]));
51 EXPECT_EQ(kTestResults[i][j],
52 scheduler.NextCaptureDelay().InMilliseconds());
53 }
54 }
55 }
56
57 TEST(CaptureSchedulerTest, RollingAverageDifferentTimes) {
58 const int kTestResults[][arraysize(kTestInputs)] = {
59 { 360, 290, 233, 133, 80, 80, 133, 233 }, // One core.
alexeypa (please no reviews) 2013/03/18 19:39:39 nit: How are there values obtained? If CaptureSche
Wez 2013/03/19 23:23:14 Then we'd just have two copies of the same calcula
60 { 180, 145, 116, 66, 50, 50, 66, 116 }, // Two cores.
61 { 90, 72, 58, 50, 50, 50, 50, 58 }, // Four cores.
62 { 50, 50, 50, 50, 50, 50, 50, 50 } // Eight cores.
63 };
64
65 for (size_t i = 0; i < arraysize(kTestResults); ++i) {
66 CaptureScheduler scheduler;
67 scheduler.SetNumOfProcessorsForTest(1 << i);
68 for (size_t j = 0; j < arraysize(kTestInputs); ++j) {
69 scheduler.RecordCaptureTime(
70 base::TimeDelta::FromMilliseconds(kTestInputs[j]));
71 scheduler.RecordEncodeTime(
72 base::TimeDelta::FromMilliseconds(
73 kTestInputs[arraysize(kTestInputs) - 1 - j]));
74 EXPECT_EQ(kTestResults[i][j],
75 scheduler.NextCaptureDelay().InMilliseconds());
76 }
77 }
78 }
79
80 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698