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

Side by Side Diff: components/exo/gamepad_unittest.cc

Issue 2493223002: Change exo::SurfaceFactoryOwner to exo::ExoCompositorFrameSink (Closed)
Patch Set: exo::Surface uses CompositorFrameSink accessor from CompositorFrameSinkHolder Created 4 years 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
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 "ash/shell.h" 5 #include "ash/shell.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/test/test_simple_task_runner.h" 8 #include "base/test/test_simple_task_runner.h"
9 #include "components/exo/buffer.h" 9 #include "components/exo/buffer.h"
10 #include "components/exo/gamepad.h" 10 #include "components/exo/gamepad.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 polling_task_runner_->RunPendingTasks(); 55 polling_task_runner_->RunPendingTasks();
56 } 56 }
57 57
58 void DestroyGamepad(MockGamepadDelegate* delegate) { 58 void DestroyGamepad(MockGamepadDelegate* delegate) {
59 EXPECT_CALL(*delegate, OnGamepadDestroying(testing::_)).Times(1); 59 EXPECT_CALL(*delegate, OnGamepadDestroying(testing::_)).Times(1);
60 mock_data_fetcher_ = nullptr; 60 mock_data_fetcher_ = nullptr;
61 gamepad_.reset(); 61 gamepad_.reset();
62 // Process tasks until polling is shut down. 62 // Process tasks until polling is shut down.
63 polling_task_runner_->RunPendingTasks(); 63 polling_task_runner_->RunPendingTasks();
64 polling_task_runner_ = nullptr; 64 polling_task_runner_ = nullptr;
65 base::RunLoop().RunUntilIdle();
reveman 2016/12/07 00:46:57 why is this needed?
Alex Z. 2016/12/07 20:09:35 Good catch. It is not. It is some leftover from de
65 } 66 }
66 67
67 void SetDataAndPostToDelegate(const blink::WebGamepads& new_data) { 68 void SetDataAndPostToDelegate(const blink::WebGamepads& new_data) {
68 ASSERT_TRUE(mock_data_fetcher_ != nullptr); 69 ASSERT_TRUE(mock_data_fetcher_ != nullptr);
69 mock_data_fetcher_->SetTestData(new_data); 70 mock_data_fetcher_->SetTestData(new_data);
70 // Run one polling cycle, which will post a task to the origin task runner. 71 // Run one polling cycle, which will post a task to the origin task runner.
71 polling_task_runner_->RunPendingTasks(); 72 polling_task_runner_->RunPendingTasks();
72 // Run origin task runner to invoke delegate. 73 // Run origin task runner to invoke delegate.
74
73 base::RunLoop().RunUntilIdle(); 75 base::RunLoop().RunUntilIdle();
74 } 76 }
75 77
76 protected: 78 protected:
77 std::unique_ptr<Gamepad> gamepad_; 79 std::unique_ptr<Gamepad> gamepad_;
78 80
79 // Task runner to simulate the polling thread. 81 // Task runner to simulate the polling thread.
80 scoped_refptr<base::TestSimpleTaskRunner> polling_task_runner_; 82 scoped_refptr<base::TestSimpleTaskRunner> polling_task_runner_;
81 83
82 // Weak reference to the mock data fetcher provided by MockDataFetcherFactory. 84 // Weak reference to the mock data fetcher provided by MockDataFetcherFactory.
(...skipping 26 matching lines...) Expand all
109 gamepad_connected.items[0].connected = true; 111 gamepad_connected.items[0].connected = true;
110 gamepad_connected.items[0].timestamp = 1; 112 gamepad_connected.items[0].timestamp = 1;
111 SetDataAndPostToDelegate(gamepad_connected); 113 SetDataAndPostToDelegate(gamepad_connected);
112 114
113 // Gamepad disconnected. 115 // Gamepad disconnected.
114 blink::WebGamepads all_disconnected; 116 blink::WebGamepads all_disconnected;
115 EXPECT_CALL(delegate, OnStateChange(false)).Times(1); 117 EXPECT_CALL(delegate, OnStateChange(false)).Times(1);
116 SetDataAndPostToDelegate(all_disconnected); 118 SetDataAndPostToDelegate(all_disconnected);
117 119
118 DestroyGamepad(&delegate); 120 DestroyGamepad(&delegate);
121 RunAllPendingInMessageLoop();
reveman 2016/12/07 00:46:57 and this?
Alex Z. 2016/12/07 20:09:36 Same as above.
119 } 122 }
120 123
121 TEST_F(GamepadTest, OnAxis) { 124 TEST_F(GamepadTest, OnAxis) {
122 std::unique_ptr<Surface> surface(new Surface); 125 std::unique_ptr<Surface> surface(new Surface);
123 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); 126 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get()));
124 gfx::Size buffer_size(10, 10); 127 gfx::Size buffer_size(10, 10);
125 std::unique_ptr<Buffer> buffer( 128 std::unique_ptr<Buffer> buffer(
126 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); 129 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
127 surface->Attach(buffer.get()); 130 surface->Attach(buffer.get());
128 surface->Commit(); 131 surface->Commit();
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 // scheduled in the next round. 216 // scheduled in the next round.
214 polling_task_runner_->RunPendingTasks(); 217 polling_task_runner_->RunPendingTasks();
215 polling_task_runner_->RunPendingTasks(); 218 polling_task_runner_->RunPendingTasks();
216 ASSERT_FALSE(polling_task_runner_->HasPendingTask()); 219 ASSERT_FALSE(polling_task_runner_->HasPendingTask());
217 220
218 DestroyGamepad(&delegate); 221 DestroyGamepad(&delegate);
219 } 222 }
220 223
221 } // namespace 224 } // namespace
222 } // namespace exo 225 } // namespace exo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698