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

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

Issue 2159283002: exo: Fix crash in out-of-order destruction of Gamepad (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
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/test/test_simple_task_runner.h" 7 #include "base/test/test_simple_task_runner.h"
8 #include "components/exo/buffer.h" 8 #include "components/exo/buffer.h"
9 #include "components/exo/gamepad.h" 9 #include "components/exo/gamepad.h"
10 #include "components/exo/gamepad_delegate.h" 10 #include "components/exo/gamepad_delegate.h"
(...skipping 29 matching lines...) Expand all
40 std::unique_ptr<device::GamepadDataFetcher> MockDataFetcherFactory() { 40 std::unique_ptr<device::GamepadDataFetcher> MockDataFetcherFactory() {
41 blink::WebGamepads initial_data; 41 blink::WebGamepads initial_data;
42 std::unique_ptr<device::MockGamepadDataFetcher> fetcher( 42 std::unique_ptr<device::MockGamepadDataFetcher> fetcher(
43 new device::MockGamepadDataFetcher(initial_data)); 43 new device::MockGamepadDataFetcher(initial_data));
44 mock_data_fetcher_ = fetcher.get(); 44 mock_data_fetcher_ = fetcher.get();
45 return std::move(fetcher); 45 return std::move(fetcher);
46 } 46 }
47 47
48 void InitializeGamepad(MockGamepadDelegate* delegate) { 48 void InitializeGamepad(MockGamepadDelegate* delegate) {
49 polling_task_runner_ = new base::TestSimpleTaskRunner(); 49 polling_task_runner_ = new base::TestSimpleTaskRunner();
50 gamepad_.reset(new Gamepad(delegate, polling_task_runner_.get(), 50 gamepad_.reset(new Gamepad(delegate, polling_task_runner_,
51 base::Bind(&GamepadTest::MockDataFetcherFactory, 51 base::Bind(&GamepadTest::MockDataFetcherFactory,
52 base::Unretained(this)))); 52 base::Unretained(this))));
53 // Run the polling task runner to have it create the data fetcher. 53 // Run the polling task runner to have it create the data fetcher.
54 polling_task_runner_->RunPendingTasks(); 54 polling_task_runner_->RunPendingTasks();
55 } 55 }
56 56
57 void DestroyGamepad(MockGamepadDelegate* delegate) { 57 void DestroyGamepad(MockGamepadDelegate* delegate) {
58 EXPECT_CALL(*delegate, OnGamepadDestroying(testing::_)).Times(1); 58 EXPECT_CALL(*delegate, OnGamepadDestroying(testing::_)).Times(1);
59 mock_data_fetcher_ = nullptr; 59 mock_data_fetcher_ = nullptr;
60 gamepad_.reset(); 60 gamepad_.reset();
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 // scheduled in the next round. 212 // scheduled in the next round.
213 polling_task_runner_->RunPendingTasks(); 213 polling_task_runner_->RunPendingTasks();
214 polling_task_runner_->RunPendingTasks(); 214 polling_task_runner_->RunPendingTasks();
215 ASSERT_FALSE(polling_task_runner_->HasPendingTask()); 215 ASSERT_FALSE(polling_task_runner_->HasPendingTask());
216 216
217 DestroyGamepad(&delegate); 217 DestroyGamepad(&delegate);
218 } 218 }
219 219
220 } // namespace 220 } // namespace
221 } // namespace exo 221 } // namespace exo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698