| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/strings/stringprintf.h" | 6 #include "base/strings/stringprintf.h" |
| 7 #include "base/test/trace_event_analyzer.h" | 7 #include "base/test/trace_event_analyzer.h" |
| 8 #include "base/win/windows_version.h" | 8 #include "base/win/windows_version.h" |
| 9 #include "chrome/browser/extensions/extension_apitest.h" | 9 #include "chrome/browser/extensions/extension_apitest.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 enum TestFlags { | 35 enum TestFlags { |
| 36 kUseGpu = 1 << 0, // Only execute test if --enable-gpu was given | 36 kUseGpu = 1 << 0, // Only execute test if --enable-gpu was given |
| 37 // on the command line. This is required for | 37 // on the command line. This is required for |
| 38 // tests that run on GPU. | 38 // tests that run on GPU. |
| 39 kForceGpuComposited = 1 << 1, // Force the test to use the compositor. | 39 kForceGpuComposited = 1 << 1, // Force the test to use the compositor. |
| 40 kDisableVsync = 1 << 2, // Do not limit framerate to vertical refresh. | 40 kDisableVsync = 1 << 2, // Do not limit framerate to vertical refresh. |
| 41 // when on GPU, nor to 60hz when not on GPU. | 41 // when on GPU, nor to 60hz when not on GPU. |
| 42 kTestThroughWebRTC = 1 << 3, // Send captured frames through webrtc | 42 kTestThroughWebRTC = 1 << 3, // Send captured frames through webrtc |
| 43 kSmallWindow = 1 << 4, // 1 = 800x600, 0 = 2000x1000 | 43 kSmallWindow = 1 << 4, // 1 = 800x600, 0 = 2000x1000 |
| 44 | |
| 45 kScaleQualityMask = 3 << 5, // two bits select which scaling quality | |
| 46 kScaleQualityDefault = 0 << 5, // to use on aura. | |
| 47 kScaleQualityFast = 1 << 5, | |
| 48 kScaleQualityGood = 2 << 5, | |
| 49 kScaleQualityBest = 3 << 5, | |
| 50 }; | 44 }; |
| 51 | 45 |
| 52 class TabCapturePerformanceTest | 46 class TabCapturePerformanceTest |
| 53 : public ExtensionApiTest, | 47 : public ExtensionApiTest, |
| 54 public testing::WithParamInterface<int> { | 48 public testing::WithParamInterface<int> { |
| 55 public: | 49 public: |
| 56 TabCapturePerformanceTest() {} | 50 TabCapturePerformanceTest() {} |
| 57 | 51 |
| 58 bool HasFlag(TestFlags flag) const { | 52 bool HasFlag(TestFlags flag) const { |
| 59 return (GetParam() & flag) == flag; | 53 return (GetParam() & flag) == flag; |
| 60 } | 54 } |
| 61 | 55 |
| 62 bool IsGpuAvailable() const { | 56 bool IsGpuAvailable() const { |
| 63 return base::CommandLine::ForCurrentProcess()->HasSwitch("enable-gpu"); | 57 return base::CommandLine::ForCurrentProcess()->HasSwitch("enable-gpu"); |
| 64 } | 58 } |
| 65 | 59 |
| 66 std::string ScalingMethod() const { | |
| 67 switch (GetParam() & kScaleQualityMask) { | |
| 68 case kScaleQualityFast: | |
| 69 return "fast"; | |
| 70 case kScaleQualityGood: | |
| 71 return "good"; | |
| 72 case kScaleQualityBest: | |
| 73 return "best"; | |
| 74 default: | |
| 75 return ""; | |
| 76 } | |
| 77 } | |
| 78 | |
| 79 std::string GetSuffixForTestFlags() { | 60 std::string GetSuffixForTestFlags() { |
| 80 std::string suffix; | 61 std::string suffix; |
| 81 if (HasFlag(kForceGpuComposited)) | 62 if (HasFlag(kForceGpuComposited)) |
| 82 suffix += "_comp"; | 63 suffix += "_comp"; |
| 83 if (HasFlag(kUseGpu)) | 64 if (HasFlag(kUseGpu)) |
| 84 suffix += "_gpu"; | 65 suffix += "_gpu"; |
| 85 if (HasFlag(kDisableVsync)) | 66 if (HasFlag(kDisableVsync)) |
| 86 suffix += "_novsync"; | 67 suffix += "_novsync"; |
| 87 if (HasFlag(kTestThroughWebRTC)) | 68 if (HasFlag(kTestThroughWebRTC)) |
| 88 suffix += "_webrtc"; | 69 suffix += "_webrtc"; |
| 89 if (!ScalingMethod().empty()) | |
| 90 suffix += "_scale" + ScalingMethod(); | |
| 91 if (HasFlag(kSmallWindow)) | 70 if (HasFlag(kSmallWindow)) |
| 92 suffix += "_small"; | 71 suffix += "_small"; |
| 93 return suffix; | 72 return suffix; |
| 94 } | 73 } |
| 95 | 74 |
| 96 void SetUp() override { | 75 void SetUp() override { |
| 97 EnablePixelOutput(); | 76 EnablePixelOutput(); |
| 98 ExtensionApiTest::SetUp(); | 77 ExtensionApiTest::SetUp(); |
| 99 } | 78 } |
| 100 | 79 |
| 101 void SetUpCommandLine(base::CommandLine* command_line) override { | 80 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 102 if (!ScalingMethod().empty()) { | |
| 103 command_line->AppendSwitchASCII(switches::kTabCaptureUpscaleQuality, | |
| 104 ScalingMethod()); | |
| 105 command_line->AppendSwitchASCII(switches::kTabCaptureDownscaleQuality, | |
| 106 ScalingMethod()); | |
| 107 } | |
| 108 | |
| 109 // Some of the tests may launch http requests through JSON or AJAX | 81 // Some of the tests may launch http requests through JSON or AJAX |
| 110 // which causes a security error (cross domain request) when the page | 82 // which causes a security error (cross domain request) when the page |
| 111 // is loaded from the local file system ( file:// ). The following switch | 83 // is loaded from the local file system ( file:// ). The following switch |
| 112 // fixes that error. | 84 // fixes that error. |
| 113 command_line->AppendSwitch(switches::kAllowFileAccessFromFiles); | 85 command_line->AppendSwitch(switches::kAllowFileAccessFromFiles); |
| 114 | 86 |
| 115 if (HasFlag(kSmallWindow)) { | 87 if (HasFlag(kSmallWindow)) { |
| 116 command_line->AppendSwitchASCII(switches::kWindowSize, "800,600"); | 88 command_line->AppendSwitchASCII(switches::kWindowSize, "800,600"); |
| 117 } else { | 89 } else { |
| 118 command_line->AppendSwitchASCII(switches::kWindowSize, "2000,1500"); | 90 command_line->AppendSwitchASCII(switches::kWindowSize, "2000,1500"); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 testing::Values( | 204 testing::Values( |
| 233 0, | 205 0, |
| 234 kUseGpu | kForceGpuComposited, | 206 kUseGpu | kForceGpuComposited, |
| 235 kDisableVsync, | 207 kDisableVsync, |
| 236 kDisableVsync | kUseGpu | kForceGpuComposited, | 208 kDisableVsync | kUseGpu | kForceGpuComposited, |
| 237 kTestThroughWebRTC, | 209 kTestThroughWebRTC, |
| 238 kTestThroughWebRTC | kUseGpu | kForceGpuComposited, | 210 kTestThroughWebRTC | kUseGpu | kForceGpuComposited, |
| 239 kTestThroughWebRTC | kDisableVsync, | 211 kTestThroughWebRTC | kDisableVsync, |
| 240 kTestThroughWebRTC | kDisableVsync | kUseGpu | kForceGpuComposited)); | 212 kTestThroughWebRTC | kDisableVsync | kUseGpu | kForceGpuComposited)); |
| 241 | 213 |
| 242 #if defined(USE_AURA) | |
| 243 // TODO(hubbe): | |
| 244 // These are temporary tests for the purpose of determining what the | |
| 245 // appropriate scaling quality is. Once that has been determined, | |
| 246 // these tests will be removed. | |
| 247 | |
| 248 const int kScalingTestBase = | |
| 249 kTestThroughWebRTC | kDisableVsync | kUseGpu | kForceGpuComposited; | |
| 250 | |
| 251 INSTANTIATE_TEST_CASE_P( | |
| 252 ScalingTests, | |
| 253 TabCapturePerformanceTest, | |
| 254 testing::Values( | |
| 255 kScalingTestBase | kScaleQualityFast, | |
| 256 kScalingTestBase | kScaleQualityGood, | |
| 257 kScalingTestBase | kScaleQualityBest, | |
| 258 kScalingTestBase | kScaleQualityFast | kSmallWindow, | |
| 259 kScalingTestBase | kScaleQualityGood | kSmallWindow, | |
| 260 kScalingTestBase | kScaleQualityBest | kSmallWindow)); | |
| 261 | |
| 262 #endif // USE_AURA | |
| OLD | NEW |