Remove some NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED
[chromium-blink-merge.git] / remoting / host / capture_scheduler_unittest.cc
bloba6ca0e6d9810e88d78fe512b2abab7b9c6e733b9
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.
5 #include "remoting/host/capture_scheduler.h"
6 #include "testing/gtest/include/gtest/gtest.h"
8 namespace remoting {
10 static const int kTestInputs[] = { 100, 50, 30, 20, 10, 30, 60, 80 };
11 static const int kMinumumFrameIntervalMs = 50;
13 TEST(CaptureSchedulerTest, SingleSampleSameTimes) {
14 const int kTestResults[][arraysize(kTestInputs)] = {
15 { 400, 200, 120, 80, 50, 120, 240, 320 }, // One core.
16 { 200, 100, 60, 50, 50, 60, 120, 160 }, // Two cores.
17 { 100, 50, 50, 50, 50, 50, 60, 80 }, // Four cores.
18 { 50, 50, 50, 50, 50, 50, 50, 50 } // Eight cores.
21 for (size_t i = 0; i < arraysize(kTestResults); ++i) {
22 for (size_t j = 0; j < arraysize(kTestInputs); ++j) {
23 CaptureScheduler scheduler;
24 scheduler.SetNumOfProcessorsForTest(1 << i);
25 scheduler.set_minimum_interval(
26 base::TimeDelta::FromMilliseconds(kMinumumFrameIntervalMs));
27 scheduler.RecordCaptureTime(
28 base::TimeDelta::FromMilliseconds(kTestInputs[j]));
29 scheduler.RecordEncodeTime(
30 base::TimeDelta::FromMilliseconds(kTestInputs[j]));
31 EXPECT_EQ(kTestResults[i][j],
32 scheduler.NextCaptureDelay().InMilliseconds()) << i << " "<< j;
37 TEST(CaptureSchedulerTest, SingleSampleDifferentTimes) {
38 const int kTestResults[][arraysize(kTestInputs)] = {
39 { 360, 220, 120, 60, 60, 120, 220, 360 }, // One core.
40 { 180, 110, 60, 50, 50, 60, 110, 180 }, // Two cores.
41 { 90, 55, 50, 50, 50, 50, 55, 90 }, // Four cores.
42 { 50, 50, 50, 50, 50, 50, 50, 50 } // Eight cores.
45 for (size_t i = 0; i < arraysize(kTestResults); ++i) {
46 for (size_t j = 0; j < arraysize(kTestInputs); ++j) {
47 CaptureScheduler scheduler;
48 scheduler.SetNumOfProcessorsForTest(1 << i);
49 scheduler.set_minimum_interval(
50 base::TimeDelta::FromMilliseconds(kMinumumFrameIntervalMs));
51 scheduler.RecordCaptureTime(
52 base::TimeDelta::FromMilliseconds(kTestInputs[j]));
53 scheduler.RecordEncodeTime(
54 base::TimeDelta::FromMilliseconds(
55 kTestInputs[arraysize(kTestInputs) - 1 - j]));
56 EXPECT_EQ(kTestResults[i][j],
57 scheduler.NextCaptureDelay().InMilliseconds());
62 TEST(CaptureSchedulerTest, RollingAverageDifferentTimes) {
63 const int kTestResults[][arraysize(kTestInputs)] = {
64 { 360, 290, 233, 133, 80, 80, 133, 233 }, // One core.
65 { 180, 145, 116, 66, 50, 50, 66, 116 }, // Two cores.
66 { 90, 72, 58, 50, 50, 50, 50, 58 }, // Four cores.
67 { 50, 50, 50, 50, 50, 50, 50, 50 } // Eight cores.
70 for (size_t i = 0; i < arraysize(kTestResults); ++i) {
71 CaptureScheduler scheduler;
72 scheduler.SetNumOfProcessorsForTest(1 << i);
73 scheduler.set_minimum_interval(
74 base::TimeDelta::FromMilliseconds(kMinumumFrameIntervalMs));
75 for (size_t j = 0; j < arraysize(kTestInputs); ++j) {
76 scheduler.RecordCaptureTime(
77 base::TimeDelta::FromMilliseconds(kTestInputs[j]));
78 scheduler.RecordEncodeTime(
79 base::TimeDelta::FromMilliseconds(
80 kTestInputs[arraysize(kTestInputs) - 1 - j]));
81 EXPECT_EQ(kTestResults[i][j],
82 scheduler.NextCaptureDelay().InMilliseconds());
87 } // namespace remoting