Fix cpu usage dvqa test on windows

Windows cpu clock has low accuracy. We need to fake some load to be sure that the clock ticks.

Bug: webrtc:12249
Change-Id: I6c3b2b0e51badd9b7a58391755a37f4d1c28af40
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/201540
Commit-Queue: Andrey Logvin <landrey@webrtc.org>
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32961}
diff --git a/test/pc/e2e/analyzer/video/default_video_quality_analyzer_test.cc b/test/pc/e2e/analyzer/video/default_video_quality_analyzer_test.cc
index 5fdd051..8b7ce86 100644
--- a/test/pc/e2e/analyzer/video/default_video_quality_analyzer_test.cc
+++ b/test/pc/e2e/analyzer/video/default_video_quality_analyzer_test.cc
@@ -8,6 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
+#include <algorithm>
 #include <map>
 #include <memory>
 #include <vector>
@@ -98,6 +99,15 @@
   return out.str();
 }
 
+void FakeCPULoad() {
+  std::vector<int> temp(100000);
+  for (size_t i = 0; i < temp.size(); ++i) {
+    temp[i] = rand();
+  }
+  std::sort(temp.begin(), temp.end());
+  ASSERT_TRUE(std::is_sorted(temp.begin(), temp.end()));
+}
+
 TEST(DefaultVideoQualityAnalyzerTest,
      MemoryOverloadedAndThenAllFramesReceived) {
   std::unique_ptr<test::FrameGeneratorInterface> frame_generator =
@@ -712,6 +722,10 @@
                             VideoQualityAnalyzerInterface::EncoderStats());
   }
 
+  // Windows CPU clock has low accuracy. We need to fake some additional load to
+  // be sure that the clock ticks (https://crbug.com/webrtc/12249).
+  FakeCPULoad();
+
   for (size_t i = 1; i < frames_order.size(); i += 2) {
     uint16_t frame_id = frames_order.at(i);
     VideoFrame received_frame = DeepCopy(captured_frames.at(frame_id));
@@ -729,15 +743,7 @@
   analyzer.Stop();
 
   double cpu_usage = analyzer.GetCpuUsagePercent();
-  // On windows bots GetProcessCpuTimeNanos doesn't work properly (returns the
-  // same number over the whole run). Adhoc solution to prevent them from
-  // failing.
-  // TODO(12249): remove it after issue is fixed.
-#if defined(WEBRTC_WIN)
-  ASSERT_GE(cpu_usage, 0);
-#else
   ASSERT_GT(cpu_usage, 0);
-#endif
 
   SleepMs(100);
   analyzer.Stop();