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

Side by Side Diff: third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DTest.cpp

Issue 2826403002: [blink] Fix crashes in CanvasRenderingContext2DTests. (Closed)
Patch Set: Created 3 years, 8 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "modules/canvas2d/CanvasRenderingContext2D.h" 5 #include "modules/canvas2d/CanvasRenderingContext2D.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include "bindings/core/v8/V8Binding.h" 8 #include "bindings/core/v8/V8Binding.h"
9 #include "bindings/core/v8/V8BindingForTesting.h" 9 #include "bindings/core/v8/V8BindingForTesting.h"
10 #include "core/dom/Document.h" 10 #include "core/dom/Document.h"
(...skipping 1385 matching lines...) Expand 10 before | Expand all | Expand 10 after
1396 void OverrideScriptEnabled(Settings& settings) { 1396 void OverrideScriptEnabled(Settings& settings) {
1397 // Simulate that we allow scripts, so that HTMLCanvasElement uses 1397 // Simulate that we allow scripts, so that HTMLCanvasElement uses
1398 // LayoutHTMLCanvas. 1398 // LayoutHTMLCanvas.
1399 settings.SetScriptEnabled(true); 1399 settings.SetScriptEnabled(true);
1400 } 1400 }
1401 1401
1402 class CanvasRenderingContext2DTestWithTestingPlatform 1402 class CanvasRenderingContext2DTestWithTestingPlatform
1403 : public CanvasRenderingContext2DTest { 1403 : public CanvasRenderingContext2DTest {
1404 protected: 1404 protected:
1405 void SetUp() override { 1405 void SetUp() override {
1406 platform_ = WTF::MakeUnique<ScopedTestingPlatformSupport<
1407 TestingPlatformSupportWithMockScheduler>>();
1406 override_settings_function_ = &OverrideScriptEnabled; 1408 override_settings_function_ = &OverrideScriptEnabled;
1407 platform_->AdvanceClockSeconds(1.); // For non-zero DocumentParserTimings. 1409 (*platform_)
1410 ->AdvanceClockSeconds(1.); // For non-zero DocumentParserTimings.
1408 CanvasRenderingContext2DTest::SetUp(); 1411 CanvasRenderingContext2DTest::SetUp();
1409 GetDocument().View()->UpdateLayout(); 1412 GetDocument().View()->UpdateLayout();
1410 } 1413 }
1411 1414
1412 void RunUntilIdle() { platform_->RunUntilIdle(); } 1415 void TearDown() override {
1416 platform_.reset();
1417 CanvasRenderingContext2DTest::TearDown();
1418 }
1413 1419
1414 ScopedTestingPlatformSupport<TestingPlatformSupportWithMockScheduler> 1420 void RunUntilIdle() { (*platform_)->RunUntilIdle(); }
1421
1422 std::unique_ptr<
1423 ScopedTestingPlatformSupport<TestingPlatformSupportWithMockScheduler>>
1415 platform_; 1424 platform_;
1416 }; 1425 };
1417 1426
1418 // https://crbug.com/708445: When the Canvas2DLayerBridge hibernates or wakes up 1427 // https://crbug.com/708445: When the Canvas2DLayerBridge hibernates or wakes up
1419 // from hibernation, the compositing reasons for the canvas element may change. 1428 // from hibernation, the compositing reasons for the canvas element may change.
1420 // In these cases, the element should request a compositing update. 1429 // In these cases, the element should request a compositing update.
1421 TEST_F(CanvasRenderingContext2DTestWithTestingPlatform, 1430 TEST_F(CanvasRenderingContext2DTestWithTestingPlatform,
1422 ElementRequestsCompositingUpdateOnHibernateAndWakeUp) { 1431 ElementRequestsCompositingUpdateOnHibernateAndWakeUp) {
1423 CreateContext(kNonOpaque); 1432 CreateContext(kNonOpaque);
1424 FakeGLES2Interface gl; 1433 FakeGLES2Interface gl;
(...skipping 25 matching lines...) Expand all
1450 layer->NeedsCompositingInputsUpdate()); 1459 layer->NeedsCompositingInputsUpdate());
1451 1460
1452 GetDocument().View()->UpdateAllLifecyclePhases(); 1461 GetDocument().View()->UpdateAllLifecyclePhases();
1453 EXPECT_FALSE(layer->NeedsCompositingInputsUpdate()); 1462 EXPECT_FALSE(layer->NeedsCompositingInputsUpdate());
1454 1463
1455 // Wake up again, which should request a compositing update synchronously. 1464 // Wake up again, which should request a compositing update synchronously.
1456 GetDocument().GetPage()->SetVisibilityState(kPageVisibilityStateVisible, 1465 GetDocument().GetPage()->SetVisibilityState(kPageVisibilityStateVisible,
1457 false); 1466 false);
1458 EXPECT_EQ(!!CANVAS2D_HIBERNATION_ENABLED, 1467 EXPECT_EQ(!!CANVAS2D_HIBERNATION_ENABLED,
1459 layer->NeedsCompositingInputsUpdate()); 1468 layer->NeedsCompositingInputsUpdate());
1469 RunUntilIdle(); // Clear task queue.
1460 } 1470 }
1461 1471
1462 } // namespace blink 1472 } // namespace blink
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