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

Side by Side Diff: cc/tiles/image_controller_unittest.cc

Issue 2668873002: cc: Add checker-imaging support to TileManager. (Closed)
Patch Set: addressed comments Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/bind.h" 5 #include "base/bind.h"
6 #include "base/optional.h" 6 #include "base/optional.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/test/test_simple_task_runner.h" 8 #include "base/test/test_simple_task_runner.h"
9 #include "base/threading/sequenced_task_runner_handle.h" 9 #include "base/threading/sequenced_task_runner_handle.h"
10 #include "cc/tiles/image_controller.h" 10 #include "cc/tiles/image_controller.h"
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 run_loop1.QuitClosure())); 440 run_loop1.QuitClosure()));
441 RunOrTimeout(&run_loop1); 441 RunOrTimeout(&run_loop1);
442 EXPECT_EQ(expected_id1, decode_client1.id()); 442 EXPECT_EQ(expected_id1, decode_client1.id());
443 EXPECT_TRUE(task->has_run()); 443 EXPECT_TRUE(task->has_run());
444 EXPECT_EQ(1, cache()->number_of_refs()); 444 EXPECT_EQ(1, cache()->number_of_refs());
445 445
446 controller()->SetImageDecodeCache(nullptr); 446 controller()->SetImageDecodeCache(nullptr);
447 EXPECT_EQ(0, cache()->number_of_refs()); 447 EXPECT_EQ(0, cache()->number_of_refs());
448 } 448 }
449 449
450 TEST_F(ImageControllerTest, DispatchesDecodeCallbacksAfterCacheChanged) {
Khushal 2017/02/17 19:05:38 I added the test. Since I stumbled onto the multip
451 scoped_refptr<SimpleTask> task(new SimpleTask);
452 cache()->SetTaskToUse(task);
453
454 base::RunLoop run_loop1;
455 DecodeClient decode_client1;
456 base::RunLoop run_loop2;
457 DecodeClient decode_client2;
458
459 controller()->QueueImageDecode(
460 image(),
461 base::Bind(&DecodeClient::Callback, base::Unretained(&decode_client1),
462 run_loop1.QuitClosure()));
463 controller()->QueueImageDecode(
464 image(),
465 base::Bind(&DecodeClient::Callback, base::Unretained(&decode_client2),
466 run_loop2.QuitClosure()));
467
468 // Now reset the image cache before decode completed callbacks are posted to
469 // the compositor thread. Ensure that the completion callbacks for the decode
470 // is still run.
471 TestableCache new_cache;
472 controller()->SetImageDecodeCache(&new_cache);
473 RunOrTimeout(&run_loop1);
474 RunOrTimeout(&run_loop2);
475 }
476
450 } // namespace 477 } // namespace
451 } // namespace cc 478 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698