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

Unified Diff: media/cast/test/skewed_single_thread_task_runner.h

Issue 289083002: Cast: Add tests for clocks being slow/fast (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: media/cast/test/skewed_single_thread_task_runner.h
diff --git a/media/cast/test/fake_single_thread_task_runner.h b/media/cast/test/skewed_single_thread_task_runner.h
similarity index 56%
copy from media/cast/test/fake_single_thread_task_runner.h
copy to media/cast/test/skewed_single_thread_task_runner.h
index 710138597f43015c777c39dedd0f09e72c726697..5ad2f8d8bb9c5705d643e165dd6afa626eceab2b 100644
--- a/media/cast/test/fake_single_thread_task_runner.h
+++ b/media/cast/test/skewed_single_thread_task_runner.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef MEDIA_CAST_TEST_FAKE_TASK_RUNNER_H_
-#define MEDIA_CAST_TEST_FAKE_TASK_RUNNER_H_
+#ifndef MEDIA_CAST_TEST_SKEWED_TASK_RUNNER_H_
+#define MEDIA_CAST_TEST_SKEWED_TASK_RUNNER_H_
#include <map>
@@ -16,13 +16,17 @@ namespace media {
namespace cast {
namespace test {
-typedef base::TestPendingTask PostedTask;
-
-class FakeSingleThreadTaskRunner : public base::SingleThreadTaskRunner {
+// This class wraps a SingleThreadTaskRunner, and allows you to scale
+// the delay for any posted task by a factor. The factor is changed by
+// calling SetSkew(). A skew of 2.0 means that all delayed task will
+// have to wait twice as long.
+class SkewedSingleThreadTaskRunner : public base::SingleThreadTaskRunner {
public:
- explicit FakeSingleThreadTaskRunner(base::SimpleTestTickClock* clock);
+ explicit SkewedSingleThreadTaskRunner(
+ const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
- void RunTasks();
+ // Set the delay multiplier to |skew|.
+ void SetSkew(double skew);
// base::SingleThreadTaskRunner implementation.
virtual bool PostDelayedTask(const tracked_objects::Location& from_here,
@@ -38,17 +42,17 @@ class FakeSingleThreadTaskRunner : public base::SingleThreadTaskRunner {
base::TimeDelta delay) OVERRIDE;
protected:
- virtual ~FakeSingleThreadTaskRunner();
+ virtual ~SkewedSingleThreadTaskRunner();
private:
- base::SimpleTestTickClock* const clock_;
- std::multimap<base::TimeTicks, PostedTask> tasks_;
+ double skew_;
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
- DISALLOW_COPY_AND_ASSIGN(FakeSingleThreadTaskRunner);
+ DISALLOW_COPY_AND_ASSIGN(SkewedSingleThreadTaskRunner);
};
} // namespace test
} // namespace cast
} // namespace media
-#endif // MEDIA_CAST_TEST_FAKE_TASK_RUNNER_H_
+#endif // MEDIA_CAST_TEST_SKEWED_TASK_RUNNER_H_
« no previous file with comments | « media/cast/test/fake_single_thread_task_runner.cc ('k') | media/cast/test/skewed_single_thread_task_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698