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

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

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