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

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

Issue 2749933002: cc: Fix a flake in ImageControllerTest.QueueImageDecodeChangeControllerWithTaskQueued (Closed)
Patch Set: threadcheckerimpl Created 3 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "cc/tiles/image_controller.h" 5 #include "cc/tiles/image_controller.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/optional.h" 7 #include "base/optional.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/test/test_simple_task_runner.h" 9 #include "base/test/test_simple_task_runner.h"
10 #include "base/threading/sequenced_task_runner_handle.h" 10 #include "base/threading/sequenced_task_runner_handle.h"
11 #include "base/threading/thread_checker_impl.h"
11 #include "cc/test/skia_common.h" 12 #include "cc/test/skia_common.h"
12 #include "cc/tiles/image_decode_cache.h" 13 #include "cc/tiles/image_decode_cache.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 15
15 namespace cc { 16 namespace cc {
16 namespace { 17 namespace {
17 18
18 class TestWorkerThread : public base::SimpleThread { 19 class TestWorkerThread : public base::SimpleThread {
19 public: 20 public:
20 TestWorkerThread() 21 TestWorkerThread()
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 base::AutoLock hold(lock_); 206 base::AutoLock hold(lock_);
206 can_run_ = true; 207 can_run_ = true;
207 run_cv_.Signal(); 208 run_cv_.Signal();
208 } 209 }
209 210
210 bool has_run() { return has_run_; } 211 bool has_run() { return has_run_; }
211 212
212 private: 213 private:
213 ~BlockingTask() override = default; 214 ~BlockingTask() override = default;
214 215
215 base::ThreadChecker thread_checker_; 216 // Use ThreadCheckerImpl, so that release builds also get correct behavior.
217 base::ThreadCheckerImpl thread_checker_;
216 bool has_run_ = false; 218 bool has_run_ = false;
217 base::Lock lock_; 219 base::Lock lock_;
218 base::ConditionVariable run_cv_; 220 base::ConditionVariable run_cv_;
219 bool can_run_ = false; 221 bool can_run_ = false;
220 222
221 DISALLOW_COPY_AND_ASSIGN(BlockingTask); 223 DISALLOW_COPY_AND_ASSIGN(BlockingTask);
222 }; 224 };
223 225
224 // For tests that exercise image controller's thread, this is the timeout value 226 // For tests that exercise image controller's thread, this is the timeout value
225 // to 227 // to allow the worker thread to do its work.
226 // allow the worker thread to do its work.
227 int kDefaultTimeoutSeconds = 10; 228 int kDefaultTimeoutSeconds = 10;
228 229
229 class ImageControllerTest : public testing::Test { 230 class ImageControllerTest : public testing::Test {
230 public: 231 public:
231 ImageControllerTest() : task_runner_(base::SequencedTaskRunnerHandle::Get()) { 232 ImageControllerTest() : task_runner_(base::SequencedTaskRunnerHandle::Get()) {
232 image_ = CreateDiscardableImage(gfx::Size(1, 1)); 233 image_ = CreateDiscardableImage(gfx::Size(1, 1));
233 } 234 }
234 ~ImageControllerTest() override = default; 235 ~ImageControllerTest() override = default;
235 236
236 void SetUp() override { 237 void SetUp() override {
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 decode_client2.result()); 583 decode_client2.result());
583 584
584 // Reset the controller since the order of destruction is wrong in this test 585 // Reset the controller since the order of destruction is wrong in this test
585 // (|other_cache| should outlive the controller. This is normally done via 586 // (|other_cache| should outlive the controller. This is normally done via
586 // SetImageDecodeCache(nullptr) or it can be done in the dtor of the cache.) 587 // SetImageDecodeCache(nullptr) or it can be done in the dtor of the cache.)
587 ResetController(); 588 ResetController();
588 } 589 }
589 590
590 } // namespace 591 } // namespace
591 } // namespace cc 592 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698