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

Unified Diff: cc/tiles/software_image_decode_controller_unittest.cc

Issue 1997743002: cc: Implement test task runner for tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove_schedule_complete
Patch Set: nits Created 4 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
« no previous file with comments | « cc/tiles/gpu_image_decode_controller_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/tiles/software_image_decode_controller_unittest.cc
diff --git a/cc/tiles/software_image_decode_controller_unittest.cc b/cc/tiles/software_image_decode_controller_unittest.cc
index 2a0695db43b225d779edee713745e482cdc2f7ec..d4fcdb5688ca08b0fd64acb38399720cabe8f263 100644
--- a/cc/tiles/software_image_decode_controller_unittest.cc
+++ b/cc/tiles/software_image_decode_controller_unittest.cc
@@ -5,8 +5,8 @@
#include "cc/tiles/software_image_decode_controller.h"
#include "cc/playback/draw_image.h"
-#include "cc/raster/tile_task.h"
#include "cc/resources/resource_format.h"
+#include "cc/test/test_tile_task_runner.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkRefCnt.h"
@@ -509,6 +509,8 @@ TEST(SoftwareImageDecodeControllerTest, GetTaskForImageSameImage) {
EXPECT_TRUE(need_unref);
EXPECT_TRUE(task.get() == another_task.get());
+ TestTileTaskRunner::ProcessTask(task.get());
+
controller.UnrefImage(draw_image);
controller.UnrefImage(draw_image);
}
@@ -555,6 +557,10 @@ TEST(SoftwareImageDecodeControllerTest,
EXPECT_TRUE(high_quality_task.get() != low_quality_task.get());
EXPECT_TRUE(medium_quality_task.get() != low_quality_task.get());
+ TestTileTaskRunner::ProcessTask(high_quality_task.get());
+ TestTileTaskRunner::ProcessTask(medium_quality_task.get());
+ TestTileTaskRunner::ProcessTask(low_quality_task.get());
+
controller.UnrefImage(high_quality_draw_image);
controller.UnrefImage(medium_quality_draw_image);
controller.UnrefImage(low_quality_draw_image);
@@ -587,6 +593,9 @@ TEST(SoftwareImageDecodeControllerTest, GetTaskForImageSameImageDifferentSize) {
EXPECT_TRUE(quarter_size_task);
EXPECT_TRUE(half_size_task.get() != quarter_size_task.get());
+ TestTileTaskRunner::ProcessTask(half_size_task.get());
+ TestTileTaskRunner::ProcessTask(quarter_size_task.get());
+
controller.UnrefImage(half_size_draw_image);
controller.UnrefImage(quarter_size_draw_image);
}
@@ -618,6 +627,9 @@ TEST(SoftwareImageDecodeControllerTest, GetTaskForImageDifferentImage) {
EXPECT_TRUE(second_task);
EXPECT_TRUE(first_task.get() != second_task.get());
+ TestTileTaskRunner::ProcessTask(first_task.get());
+ TestTileTaskRunner::ProcessTask(second_task.get());
+
controller.UnrefImage(first_draw_image);
controller.UnrefImage(second_draw_image);
}
@@ -637,8 +649,8 @@ TEST(SoftwareImageDecodeControllerTest, GetTaskForImageAlreadyDecoded) {
EXPECT_TRUE(need_unref);
EXPECT_TRUE(task);
- // TODO(prashant.n): Implement proper task life cycle. crbug.com/599863.
- task->RunOnWorkerThread();
+ TestTileTaskRunner::ScheduleTask(task.get());
+ TestTileTaskRunner::RunTask(task.get());
scoped_refptr<TileTask> another_task;
need_unref = controller.GetTaskForImageAndRef(
@@ -646,7 +658,7 @@ TEST(SoftwareImageDecodeControllerTest, GetTaskForImageAlreadyDecoded) {
EXPECT_TRUE(need_unref);
EXPECT_FALSE(another_task);
- task->OnTaskCompleted();
+ TestTileTaskRunner::CompleteTask(task.get());
controller.UnrefImage(draw_image);
controller.UnrefImage(draw_image);
@@ -667,7 +679,8 @@ TEST(SoftwareImageDecodeControllerTest, GetTaskForImageAlreadyPrerolled) {
EXPECT_TRUE(need_unref);
EXPECT_TRUE(task);
- task->RunOnWorkerThread();
+ TestTileTaskRunner::ScheduleTask(task.get());
+ TestTileTaskRunner::RunTask(task.get());
scoped_refptr<TileTask> another_task;
need_unref = controller.GetTaskForImageAndRef(
@@ -675,7 +688,7 @@ TEST(SoftwareImageDecodeControllerTest, GetTaskForImageAlreadyPrerolled) {
EXPECT_TRUE(need_unref);
EXPECT_FALSE(another_task);
- task->OnTaskCompleted();
+ TestTileTaskRunner::CompleteTask(task.get());
scoped_refptr<TileTask> third_task;
need_unref = controller.GetTaskForImageAndRef(
@@ -710,7 +723,8 @@ TEST(SoftwareImageDecodeControllerTest, GetTaskForImageCanceledGetsNewTask) {
EXPECT_TRUE(another_task.get() == task.get());
// Didn't run the task, complete it (it was canceled).
- task->OnTaskCompleted();
+ TestTileTaskRunner::CancelTask(task.get());
+ TestTileTaskRunner::CompleteTask(task.get());
// Fully cancel everything (so the raster would unref things).
controller.UnrefImage(draw_image);
@@ -724,6 +738,8 @@ TEST(SoftwareImageDecodeControllerTest, GetTaskForImageCanceledGetsNewTask) {
EXPECT_TRUE(third_task);
EXPECT_FALSE(third_task.get() == task.get());
+ TestTileTaskRunner::ProcessTask(third_task.get());
+
controller.UnrefImage(draw_image);
}
@@ -750,7 +766,8 @@ TEST(SoftwareImageDecodeControllerTest,
EXPECT_TRUE(another_task.get() == task.get());
// Didn't run the task, complete it (it was canceled).
- task->OnTaskCompleted();
+ TestTileTaskRunner::CancelTask(task.get());
+ TestTileTaskRunner::CompleteTask(task.get());
// Note that here, everything is reffed, but a new task is created. This is
// possible with repeated schedule/cancel operations.
@@ -761,6 +778,8 @@ TEST(SoftwareImageDecodeControllerTest,
EXPECT_TRUE(third_task);
EXPECT_FALSE(third_task.get() == task.get());
+ TestTileTaskRunner::ProcessTask(third_task.get());
+
// 3 Unrefs!
controller.UnrefImage(draw_image);
controller.UnrefImage(draw_image);
@@ -782,9 +801,7 @@ TEST(SoftwareImageDecodeControllerTest, GetDecodedImageForDraw) {
EXPECT_TRUE(need_unref);
EXPECT_TRUE(task);
- task->RunOnWorkerThread();
-
- task->OnTaskCompleted();
+ TestTileTaskRunner::ProcessTask(task.get());
DecodedDrawImage decoded_draw_image =
controller.GetDecodedImageForDraw(draw_image);
@@ -817,9 +834,7 @@ TEST(SoftwareImageDecodeControllerTest,
EXPECT_TRUE(need_unref);
EXPECT_TRUE(task);
- task->RunOnWorkerThread();
-
- task->OnTaskCompleted();
+ TestTileTaskRunner::ProcessTask(task.get());
DecodedDrawImage decoded_draw_image =
controller.GetDecodedImageForDraw(draw_image);
@@ -919,9 +934,7 @@ TEST(SoftwareImageDecodeControllerTest,
EXPECT_TRUE(need_unref);
EXPECT_TRUE(task);
- task->RunOnWorkerThread();
-
- task->OnTaskCompleted();
+ TestTileTaskRunner::ProcessTask(task.get());
DecodedDrawImage another_decoded_draw_image =
controller.GetDecodedImageForDraw(draw_image);
@@ -970,9 +983,7 @@ TEST(SoftwareImageDecodeControllerTest,
// instead of decoding again.
controller.DrawWithImageFinished(draw_image, decoded_draw_image);
- task->RunOnWorkerThread();
-
- task->OnTaskCompleted();
+ TestTileTaskRunner::ProcessTask(task.get());
DecodedDrawImage another_decoded_draw_image =
controller.GetDecodedImageForDraw(draw_image);
@@ -1048,6 +1059,8 @@ TEST(SoftwareImageDecodeControllerTest, LowQualityFilterIsHandled) {
EXPECT_TRUE(task);
EXPECT_TRUE(need_unref);
+ TestTileTaskRunner::ProcessTask(task.get());
+
DecodedDrawImage decoded_draw_image =
controller.GetDecodedImageForDraw(draw_image);
EXPECT_TRUE(decoded_draw_image.image());
@@ -1074,6 +1087,8 @@ TEST(SoftwareImageDecodeControllerTest, LowQualityScaledSubrectIsHandled) {
EXPECT_TRUE(task);
EXPECT_TRUE(need_unref);
+ TestTileTaskRunner::ProcessTask(task.get());
+
DecodedDrawImage decoded_draw_image =
controller.GetDecodedImageForDraw(draw_image);
EXPECT_TRUE(decoded_draw_image.image());
@@ -1102,6 +1117,8 @@ TEST(SoftwareImageDecodeControllerTest, NoneQualityScaledSubrectIsHandled) {
EXPECT_TRUE(task);
EXPECT_TRUE(need_unref);
+ TestTileTaskRunner::ProcessTask(task.get());
+
DecodedDrawImage decoded_draw_image =
controller.GetDecodedImageForDraw(draw_image);
EXPECT_TRUE(decoded_draw_image.image());
@@ -1131,6 +1148,8 @@ TEST(SoftwareImageDecodeControllerTest, MediumQualityAt01_5ScaleIsHandled) {
EXPECT_TRUE(task);
EXPECT_TRUE(need_unref);
+ TestTileTaskRunner::ProcessTask(task.get());
+
DecodedDrawImage decoded_draw_image =
controller.GetDecodedImageForDraw(draw_image);
EXPECT_TRUE(decoded_draw_image.image());
@@ -1161,6 +1180,8 @@ TEST(SoftwareImageDecodeControllerTest, MediumQualityAt1_0ScaleIsHandled) {
EXPECT_TRUE(task);
EXPECT_TRUE(need_unref);
+ TestTileTaskRunner::ProcessTask(task.get());
+
DecodedDrawImage decoded_draw_image =
controller.GetDecodedImageForDraw(draw_image);
EXPECT_TRUE(decoded_draw_image.image());
@@ -1191,6 +1212,8 @@ TEST(SoftwareImageDecodeControllerTest, MediumQualityAt0_75ScaleIsHandled) {
EXPECT_TRUE(task);
EXPECT_TRUE(need_unref);
+ TestTileTaskRunner::ProcessTask(task.get());
+
DecodedDrawImage decoded_draw_image =
controller.GetDecodedImageForDraw(draw_image);
EXPECT_TRUE(decoded_draw_image.image());
@@ -1221,6 +1244,8 @@ TEST(SoftwareImageDecodeControllerTest, MediumQualityAt0_5ScaleIsHandled) {
EXPECT_TRUE(task);
EXPECT_TRUE(need_unref);
+ TestTileTaskRunner::ProcessTask(task.get());
+
DecodedDrawImage decoded_draw_image =
controller.GetDecodedImageForDraw(draw_image);
EXPECT_TRUE(decoded_draw_image.image());
@@ -1251,6 +1276,8 @@ TEST(SoftwareImageDecodeControllerTest, MediumQualityAt0_49ScaleIsHandled) {
EXPECT_TRUE(task);
EXPECT_TRUE(need_unref);
+ TestTileTaskRunner::ProcessTask(task.get());
+
DecodedDrawImage decoded_draw_image =
controller.GetDecodedImageForDraw(draw_image);
EXPECT_TRUE(decoded_draw_image.image());
@@ -1281,6 +1308,8 @@ TEST(SoftwareImageDecodeControllerTest, MediumQualityAt0_1ScaleIsHandled) {
EXPECT_TRUE(task);
EXPECT_TRUE(need_unref);
+ TestTileTaskRunner::ProcessTask(task.get());
+
DecodedDrawImage decoded_draw_image =
controller.GetDecodedImageForDraw(draw_image);
EXPECT_TRUE(decoded_draw_image.image());
@@ -1311,6 +1340,8 @@ TEST(SoftwareImageDecodeControllerTest, MediumQualityAt0_01ScaleIsHandled) {
EXPECT_TRUE(task);
EXPECT_TRUE(need_unref);
+ TestTileTaskRunner::ProcessTask(task.get());
+
DecodedDrawImage decoded_draw_image =
controller.GetDecodedImageForDraw(draw_image);
EXPECT_TRUE(decoded_draw_image.image());
@@ -1373,6 +1404,8 @@ TEST(SoftwareImageDecodeControllerTest,
EXPECT_TRUE(task_49);
EXPECT_TRUE(need_unref_49);
+ TestTileTaskRunner::ProcessTask(task_49.get());
+
DecodedDrawImage decoded_draw_image_50 =
controller.GetDecodedImageForDraw(draw_image_50);
EXPECT_TRUE(decoded_draw_image_50.image());
« no previous file with comments | « cc/tiles/gpu_image_decode_controller_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698