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

Side by Side Diff: Source/core/platform/graphics/chromium/Canvas2DLayerBridgeTest.cpp

Issue 16032003: Fixing Canvas2DLayerBridge to handle lost graphics contexts (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Resolved merge with rate limiter CL Created 7 years, 4 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 class MockCanvasContext : public FakeWebGraphicsContext3D { 48 class MockCanvasContext : public FakeWebGraphicsContext3D {
49 public: 49 public:
50 MOCK_METHOD0(flush, void(void)); 50 MOCK_METHOD0(flush, void(void));
51 MOCK_METHOD0(createTexture, unsigned(void)); 51 MOCK_METHOD0(createTexture, unsigned(void));
52 MOCK_METHOD1(deleteTexture, void(unsigned)); 52 MOCK_METHOD1(deleteTexture, void(unsigned));
53 53
54 virtual GrGLInterface* onCreateGrGLInterface() OVERRIDE { return 0; } 54 virtual GrGLInterface* onCreateGrGLInterface() OVERRIDE { return 0; }
55 }; 55 };
56 56
57 class FakeCanvas2DLayerBridge : public Canvas2DLayerBridge {
58 public:
59 static PassOwnPtr<FakeCanvas2DLayerBridge> create(PassRefPtr<GraphicsContext 3D> context, SkDeferredCanvas* canvas, OpacityMode opacityMode)
60 {
61 return adoptPtr(new FakeCanvas2DLayerBridge(context, canvas, opacityMode ));
62 }
63 protected:
64 FakeCanvas2DLayerBridge(PassRefPtr<GraphicsContext3D> context, SkDeferredCan vas* canvas, OpacityMode opacityMode) :
65 Canvas2DLayerBridge(context, canvas, opacityMode)
66 { }
67 };
68
57 } // namespace 69 } // namespace
58 70
59 class Canvas2DLayerBridgeTest : public Test { 71 class Canvas2DLayerBridgeTest : public Test {
60 protected: 72 protected:
61 void fullLifecycleTest() 73 void fullLifecycleTest()
62 { 74 {
63 RefPtr<GraphicsContext3D> mainContext = GraphicsContext3D::createGraphic sContextFromWebContext(adoptPtr(new MockCanvasContext)); 75 RefPtr<GraphicsContext3D> mainContext = GraphicsContext3D::createGraphic sContextFromWebContext(adoptPtr(new MockCanvasContext));
64 76
65 MockCanvasContext& mainMock = *static_cast<MockCanvasContext*>(mainConte xt->webContext()); 77 MockCanvasContext& mainMock = *static_cast<MockCanvasContext*>(mainConte xt->webContext());
66 78
67 SkDevice device(SkBitmap::kARGB_8888_Config, 300, 150); 79 SkDevice device(SkBitmap::kARGB_8888_Config, 300, 150);
68 SkDeferredCanvas canvas(&device); 80 SkDeferredCanvas canvas(&device);
69 81
70 ::testing::Mock::VerifyAndClearExpectations(&mainMock); 82 ::testing::Mock::VerifyAndClearExpectations(&mainMock);
71 83
72 OwnPtr<Canvas2DLayerBridge> bridge = Canvas2DLayerBridge::create(mainCon text.release(), &canvas, Canvas2DLayerBridge::NonOpaque); 84 OwnPtr<Canvas2DLayerBridge> bridge = FakeCanvas2DLayerBridge::create(mai nContext.release(), &canvas, Canvas2DLayerBridge::NonOpaque);
73 85
74 ::testing::Mock::VerifyAndClearExpectations(&mainMock); 86 ::testing::Mock::VerifyAndClearExpectations(&mainMock);
75 87
76 EXPECT_CALL(mainMock, flush()); 88 EXPECT_CALL(mainMock, flush());
77 unsigned textureId = bridge->backBufferTexture(); 89 unsigned textureId = bridge->backBufferTexture();
78 EXPECT_EQ(textureId, 0u); 90 EXPECT_EQ(textureId, 0u);
79 91
80 ::testing::Mock::VerifyAndClearExpectations(&mainMock); 92 ::testing::Mock::VerifyAndClearExpectations(&mainMock);
81 93
82 bridge.clear(); 94 bridge.clear();
83 95
84 ::testing::Mock::VerifyAndClearExpectations(&mainMock); 96 ::testing::Mock::VerifyAndClearExpectations(&mainMock);
85 } 97 }
86 }; 98 };
87 99
88 namespace { 100 namespace {
89 101
90 TEST_F(Canvas2DLayerBridgeTest, testFullLifecycleSingleThreaded) 102 TEST_F(Canvas2DLayerBridgeTest, testFullLifecycleSingleThreaded)
91 { 103 {
92 fullLifecycleTest(); 104 fullLifecycleTest();
93 } 105 }
94 106
95 } // namespace 107 } // namespace
OLDNEW
« no previous file with comments | « Source/core/platform/graphics/chromium/Canvas2DLayerBridge.cpp ('k') | Source/core/testing/Internals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698