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

Side by Side Diff: ui/compositor/compositor_unittest.cc

Issue 1388543004: aura: Support releasing the OutputSurface() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@startcomp
Patch Set: Created 5 years, 2 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 | « ui/compositor/compositor.cc ('k') | 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "base/run_loop.h" 5 #include "base/run_loop.h"
6 #include "base/thread_task_runner_handle.h" 6 #include "base/thread_task_runner_handle.h"
7 #include "cc/output/begin_frame_args.h" 7 #include "cc/output/begin_frame_args.h"
8 #include "cc/test/begin_frame_args_test.h" 8 #include "cc/test/begin_frame_args_test.h"
9 #include "testing/gmock/include/gmock/gmock.h" 9 #include "testing/gmock/include/gmock/gmock.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "ui/compositor/compositor.h" 11 #include "ui/compositor/compositor.h"
12 #include "ui/compositor/layer.h"
12 #include "ui/compositor/test/context_factories_for_test.h" 13 #include "ui/compositor/test/context_factories_for_test.h"
14 #include "ui/compositor/test/draw_waiter_for_test.h"
13 15
14 using testing::Mock; 16 using testing::Mock;
15 using testing::_; 17 using testing::_;
16 18
17 namespace ui { 19 namespace ui {
18 namespace { 20 namespace {
19 21
20 class MockCompositorBeginFrameObserver : public CompositorBeginFrameObserver { 22 class MockCompositorBeginFrameObserver : public CompositorBeginFrameObserver {
21 public: 23 public:
22 MOCK_METHOD1(OnSendBeginFrame, void(const cc::BeginFrameArgs&)); 24 MOCK_METHOD1(OnSendBeginFrame, void(const cc::BeginFrameArgs&));
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 // So, it is not used for newly added observer. 120 // So, it is not used for newly added observer.
119 EXPECT_CALL(test_observer2, OnSendBeginFrame(_)).Times(0); 121 EXPECT_CALL(test_observer2, OnSendBeginFrame(_)).Times(0);
120 compositor()->RemoveBeginFrameObserver(&test_observer); 122 compositor()->RemoveBeginFrameObserver(&test_observer);
121 compositor()->RemoveBeginFrameObserver(&test_observer2); 123 compositor()->RemoveBeginFrameObserver(&test_observer2);
122 compositor()->AddBeginFrameObserver(&test_observer2); 124 compositor()->AddBeginFrameObserver(&test_observer2);
123 Mock::VerifyAndClearExpectations(&test_observer2); 125 Mock::VerifyAndClearExpectations(&test_observer2);
124 126
125 compositor()->RemoveBeginFrameObserver(&test_observer2); 127 compositor()->RemoveBeginFrameObserver(&test_observer2);
126 } 128 }
127 129
130 TEST_F(CompositorTest, ReleaseWidgetWithOutputSurfaceNeverCreated) {
131 compositor()->SetVisible(false);
132 EXPECT_EQ(gfx::kNullAcceleratedWidget,
133 compositor()->ReleaseAcceleratedWidget());
134 compositor()->SetAcceleratedWidget(gfx::kNullAcceleratedWidget);
135 compositor()->SetVisible(true);
136 }
137
138 TEST_F(CompositorTest, CreateAndReleaseOutputSurface) {
139 scoped_ptr<Layer> root_layer(new Layer(ui::LAYER_SOLID_COLOR));
140 root_layer->SetBounds(gfx::Rect(10, 10));
141 compositor()->SetRootLayer(root_layer.get());
142 compositor()->SetScaleAndSize(1.0f, gfx::Size(10, 10));
143 DCHECK(compositor()->IsVisible());
144 compositor()->ScheduleDraw();
145 DrawWaiterForTest::WaitForCompositingEnded(compositor());
146 compositor()->SetVisible(false);
147 EXPECT_EQ(gfx::kNullAcceleratedWidget,
danakj 2015/10/06 18:28:12 might be worth a test that verifies it gets back t
no sievers 2015/10/06 23:46:27 But it goes into the non-offscreen creation path t
danakj 2015/10/07 20:44:42 I was thinking of https://code.google.com/p/chromi
148 compositor()->ReleaseAcceleratedWidget());
149 compositor()->SetAcceleratedWidget(gfx::kNullAcceleratedWidget);
150 compositor()->SetVisible(true);
151 compositor()->ScheduleDraw();
152 DrawWaiterForTest::WaitForCompositingEnded(compositor());
153 compositor()->SetRootLayer(nullptr);
154 }
155
128 } // namespace ui 156 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/compositor.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698