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

Side by Side Diff: Source/platform/graphics/RecordingImageBufferSurfaceTest.cpp

Issue 1184673003: Fix unit test style in Source/platform/, part 2. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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 // 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 "config.h" 5 #include "config.h"
6
7 #include "platform/graphics/RecordingImageBufferSurface.h" 6 #include "platform/graphics/RecordingImageBufferSurface.h"
8 7
9 #include "platform/graphics/GraphicsContext.h" 8 #include "platform/graphics/GraphicsContext.h"
10 #include "platform/graphics/ImageBuffer.h" 9 #include "platform/graphics/ImageBuffer.h"
11 #include "platform/graphics/ImageBufferClient.h" 10 #include "platform/graphics/ImageBufferClient.h"
12 #include "platform/graphics/UnacceleratedImageBufferSurface.h" 11 #include "platform/graphics/UnacceleratedImageBufferSurface.h"
13 #include "public/platform/Platform.h" 12 #include "public/platform/Platform.h"
14 #include "public/platform/WebThread.h" 13 #include "public/platform/WebThread.h"
15 #include "public/platform/WebTraceLocation.h" 14 #include "public/platform/WebTraceLocation.h"
16 #include "third_party/skia/include/core/SkCanvas.h" 15 #include "third_party/skia/include/core/SkCanvas.h"
17 #include "third_party/skia/include/core/SkPictureRecorder.h" 16 #include "third_party/skia/include/core/SkPictureRecorder.h"
18 #include "wtf/OwnPtr.h" 17 #include "wtf/OwnPtr.h"
19 #include "wtf/PassOwnPtr.h" 18 #include "wtf/PassOwnPtr.h"
20 #include "wtf/RefPtr.h" 19 #include "wtf/RefPtr.h"
21
22 #include <gmock/gmock.h> 20 #include <gmock/gmock.h>
23 #include <gtest/gtest.h> 21 #include <gtest/gtest.h>
24 22
25 using namespace blink;
26 using testing::Test; 23 using testing::Test;
27 24
28 namespace { 25 namespace blink {
29 26
30 class FakeImageBufferClient : public ImageBufferClient, public WebThread::TaskOb server { 27 class FakeImageBufferClient : public ImageBufferClient, public WebThread::TaskOb server {
31 public: 28 public:
32 FakeImageBufferClient(ImageBuffer* imageBuffer) 29 FakeImageBufferClient(ImageBuffer* imageBuffer)
33 : m_isDirty(false) 30 : m_isDirty(false)
34 , m_imageBuffer(imageBuffer) 31 , m_imageBuffer(imageBuffer)
35 , m_frameCount(0) 32 , m_frameCount(0)
36 { } 33 { }
37 34
38 virtual ~FakeImageBufferClient() { } 35 ~FakeImageBufferClient() override { }
39 36
40 // ImageBufferClient implementation 37 // ImageBufferClient implementation
41 virtual void notifySurfaceInvalid() override { } 38 void notifySurfaceInvalid() override { }
42 virtual bool isDirty() override { return m_isDirty; }; 39 bool isDirty() override { return m_isDirty; };
43 virtual void didFinalizeFrame() override 40 void didFinalizeFrame() override
44 { 41 {
45 if (m_isDirty) { 42 if (m_isDirty) {
46 Platform::current()->currentThread()->removeTaskObserver(this); 43 Platform::current()->currentThread()->removeTaskObserver(this);
47 m_isDirty = false; 44 m_isDirty = false;
48 } 45 }
49 ++m_frameCount; 46 ++m_frameCount;
50 } 47 }
51 48
52 // TaskObserver implementation 49 // TaskObserver implementation
53 virtual void willProcessTask() override { ASSERT_NOT_REACHED(); } 50 void willProcessTask() override { ASSERT_NOT_REACHED(); }
54 virtual void didProcessTask() override 51 void didProcessTask() override
55 { 52 {
56 ASSERT_TRUE(m_isDirty); 53 ASSERT_TRUE(m_isDirty);
57 FloatRect dirtyRect(0, 0, 1, 1); 54 FloatRect dirtyRect(0, 0, 1, 1);
58 m_imageBuffer->finalizeFrame(dirtyRect); 55 m_imageBuffer->finalizeFrame(dirtyRect);
59 ASSERT_FALSE(m_isDirty); 56 ASSERT_FALSE(m_isDirty);
60 } 57 }
61 virtual void restoreCanvasMatrixClipStack() override { }; 58 void restoreCanvasMatrixClipStack() override { };
62 59
63 void fakeDraw() 60 void fakeDraw()
64 { 61 {
65 if (m_isDirty) 62 if (m_isDirty)
66 return; 63 return;
67 m_isDirty = true; 64 m_isDirty = true;
68 Platform::current()->currentThread()->addTaskObserver(this); 65 Platform::current()->currentThread()->addTaskObserver(this);
69 } 66 }
70 67
71 int frameCount() { return m_frameCount; } 68 int frameCount() { return m_frameCount; }
(...skipping 15 matching lines...) Expand all
87 } 84 }
88 85
89 virtual ~MockSurfaceFactory() { } 86 virtual ~MockSurfaceFactory() { }
90 87
91 int createSurfaceCount() { return m_createSurfaceCount; } 88 int createSurfaceCount() { return m_createSurfaceCount; }
92 89
93 private: 90 private:
94 int m_createSurfaceCount; 91 int m_createSurfaceCount;
95 }; 92 };
96 93
97 } // unnamed namespace
98
99 class RecordingImageBufferSurfaceTest : public Test { 94 class RecordingImageBufferSurfaceTest : public Test {
100 protected: 95 protected:
101 RecordingImageBufferSurfaceTest() 96 RecordingImageBufferSurfaceTest()
102 { 97 {
103 OwnPtr<MockSurfaceFactory> surfaceFactory = adoptPtr(new MockSurfaceFact ory()); 98 OwnPtr<MockSurfaceFactory> surfaceFactory = adoptPtr(new MockSurfaceFact ory());
104 m_surfaceFactory = surfaceFactory.get(); 99 m_surfaceFactory = surfaceFactory.get();
105 OwnPtr<RecordingImageBufferSurface> testSurface = adoptPtr(new Recording ImageBufferSurface(IntSize(10, 10), surfaceFactory.release())); 100 OwnPtr<RecordingImageBufferSurface> testSurface = adoptPtr(new Recording ImageBufferSurface(IntSize(10, 10), surfaceFactory.release()));
106 m_testSurface = testSurface.get(); 101 m_testSurface = testSurface.get();
107 // We create an ImageBuffer in order for the testSurface to be 102 // We create an ImageBuffer in order for the testSurface to be
108 // properly initialized with a GraphicsContext 103 // properly initialized with a GraphicsContext
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 320
326 void enterRunLoop() { m_currentThread.enterRunLoop(); } 321 void enterRunLoop() { m_currentThread.enterRunLoop(); }
327 private: 322 private:
328 CurrentThreadMock m_currentThread; 323 CurrentThreadMock m_currentThread;
329 }; 324 };
330 325
331 CurrentThreadPlatformMock m_mockPlatform; 326 CurrentThreadPlatformMock m_mockPlatform;
332 Platform* m_oldPlatform; 327 Platform* m_oldPlatform;
333 }; 328 };
334 329
330 } // anonymous namespace
335 331
336 #define DEFINE_TEST_TASK_WRAPPER_CLASS(TEST_METHOD) \ 332 #define DEFINE_TEST_TASK_WRAPPER_CLASS(TEST_METHOD) \
337 class TestWrapperTask_ ## TEST_METHOD : public WebThread::Task { \ 333 class TestWrapperTask_ ## TEST_METHOD : public WebThread::Task { \
338 public: \ 334 public: \
339 TestWrapperTask_ ## TEST_METHOD(RecordingImageBufferSurfaceTest* test) : m_test(test) { } \ 335 TestWrapperTask_ ## TEST_METHOD(RecordingImageBufferSurfaceTest* test) : m_test(test) { } \
340 virtual void run() override { m_test->TEST_METHOD(); } \ 336 virtual void run() override { m_test->TEST_METHOD(); } \
341 private: \ 337 private: \
342 RecordingImageBufferSurfaceTest* m_test; \ 338 RecordingImageBufferSurfaceTest* m_test; \
343 }; 339 };
344 340
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 expectDisplayListEnabled(true); 386 expectDisplayListEnabled(true);
391 } 387 }
392 388
393 DEFINE_TEST_TASK_WRAPPER_CLASS(testClearRect) 389 DEFINE_TEST_TASK_WRAPPER_CLASS(testClearRect)
394 TEST_F(RecordingImageBufferSurfaceTest, testClearRect) 390 TEST_F(RecordingImageBufferSurfaceTest, testClearRect)
395 { 391 {
396 CALL_TEST_TASK_WRAPPER(testClearRect); 392 CALL_TEST_TASK_WRAPPER(testClearRect);
397 expectDisplayListEnabled(true); 393 expectDisplayListEnabled(true);
398 } 394 }
399 395
400 } // namespace 396 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698