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

Side by Side Diff: content/browser/gamepad/gamepad_provider_unittest.cc

Issue 1874893002: Convert //content/browser from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 | « content/browser/gamepad/gamepad_provider.cc ('k') | content/browser/gamepad/gamepad_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/gamepad/gamepad_provider.h"
6
7 #include <memory>
8
5 #include "base/macros.h" 9 #include "base/macros.h"
6 #include "base/memory/scoped_ptr.h"
7 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
8 #include "build/build_config.h" 11 #include "build/build_config.h"
9 #include "content/browser/gamepad/gamepad_data_fetcher.h" 12 #include "content/browser/gamepad/gamepad_data_fetcher.h"
10 #include "content/browser/gamepad/gamepad_provider.h"
11 #include "content/browser/gamepad/gamepad_test_helpers.h" 13 #include "content/browser/gamepad/gamepad_test_helpers.h"
12 #include "content/common/gamepad_hardware_buffer.h" 14 #include "content/common/gamepad_hardware_buffer.h"
13 #include "content/common/gamepad_messages.h" 15 #include "content/common/gamepad_messages.h"
14 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
15 17
16 namespace content { 18 namespace content {
17 19
18 namespace { 20 namespace {
19 21
20 using blink::WebGamepads; 22 using blink::WebGamepads;
(...skipping 21 matching lines...) Expand all
42 bool has_user_gesture_; 44 bool has_user_gesture_;
43 base::WeakPtrFactory<UserGestureListener> weak_factory_; 45 base::WeakPtrFactory<UserGestureListener> weak_factory_;
44 }; 46 };
45 47
46 // Main test fixture 48 // Main test fixture
47 class GamepadProviderTest : public testing::Test, public GamepadTestHelper { 49 class GamepadProviderTest : public testing::Test, public GamepadTestHelper {
48 public: 50 public:
49 GamepadProvider* CreateProvider(const WebGamepads& test_data) { 51 GamepadProvider* CreateProvider(const WebGamepads& test_data) {
50 mock_data_fetcher_ = new MockGamepadDataFetcher(test_data); 52 mock_data_fetcher_ = new MockGamepadDataFetcher(test_data);
51 provider_.reset(new GamepadProvider( 53 provider_.reset(new GamepadProvider(
52 scoped_ptr<GamepadDataFetcher>(mock_data_fetcher_))); 54 std::unique_ptr<GamepadDataFetcher>(mock_data_fetcher_)));
53 return provider_.get(); 55 return provider_.get();
54 } 56 }
55 57
56 protected: 58 protected:
57 GamepadProviderTest() { 59 GamepadProviderTest() {
58 } 60 }
59 61
60 scoped_ptr<GamepadProvider> provider_; 62 std::unique_ptr<GamepadProvider> provider_;
61 63
62 // Pointer owned by the provider. 64 // Pointer owned by the provider.
63 MockGamepadDataFetcher* mock_data_fetcher_; 65 MockGamepadDataFetcher* mock_data_fetcher_;
64 66
65 DISALLOW_COPY_AND_ASSIGN(GamepadProviderTest); 67 DISALLOW_COPY_AND_ASSIGN(GamepadProviderTest);
66 }; 68 };
67 69
68 // Crashes. http://crbug.com/106163 70 // Crashes. http://crbug.com/106163
69 // crbug.com/147549 71 // crbug.com/147549
70 #if defined(OS_ANDROID) 72 #if defined(OS_ANDROID)
(...skipping 16 matching lines...) Expand all
87 GamepadProvider* provider = CreateProvider(test_data); 89 GamepadProvider* provider = CreateProvider(test_data);
88 provider->Resume(); 90 provider->Resume();
89 91
90 message_loop().RunUntilIdle(); 92 message_loop().RunUntilIdle();
91 93
92 mock_data_fetcher_->WaitForDataRead(); 94 mock_data_fetcher_->WaitForDataRead();
93 95
94 // Renderer-side, pull data out of poll buffer. 96 // Renderer-side, pull data out of poll buffer.
95 base::SharedMemoryHandle handle = provider->GetSharedMemoryHandleForProcess( 97 base::SharedMemoryHandle handle = provider->GetSharedMemoryHandleForProcess(
96 base::GetCurrentProcessHandle()); 98 base::GetCurrentProcessHandle());
97 scoped_ptr<base::SharedMemory> shared_memory( 99 std::unique_ptr<base::SharedMemory> shared_memory(
98 new base::SharedMemory(handle, true)); 100 new base::SharedMemory(handle, true));
99 EXPECT_TRUE(shared_memory->Map(sizeof(GamepadHardwareBuffer))); 101 EXPECT_TRUE(shared_memory->Map(sizeof(GamepadHardwareBuffer)));
100 void* mem = shared_memory->memory(); 102 void* mem = shared_memory->memory();
101 103
102 GamepadHardwareBuffer* hwbuf = static_cast<GamepadHardwareBuffer*>(mem); 104 GamepadHardwareBuffer* hwbuf = static_cast<GamepadHardwareBuffer*>(mem);
103 // See gamepad_hardware_buffer.h for details on the read discipline. 105 // See gamepad_hardware_buffer.h for details on the read discipline.
104 WebGamepads output; 106 WebGamepads output;
105 107
106 base::subtle::Atomic32 version; 108 base::subtle::Atomic32 version;
107 do { 109 do {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 mock_data_fetcher_->WaitForDataReadAndCallbacksIssued(); 153 mock_data_fetcher_->WaitForDataReadAndCallbacksIssued();
152 154
153 // It should have issued our callback. 155 // It should have issued our callback.
154 message_loop().RunUntilIdle(); 156 message_loop().RunUntilIdle();
155 EXPECT_TRUE(listener.has_user_gesture()); 157 EXPECT_TRUE(listener.has_user_gesture());
156 } 158 }
157 159
158 } // namespace 160 } // namespace
159 161
160 } // namespace content 162 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/gamepad/gamepad_provider.cc ('k') | content/browser/gamepad/gamepad_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698