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

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

Issue 1586663006: Refactoring gamepad polling to support dynamically added sources (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 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 <string.h> 5 #include <string.h>
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "content/browser/gamepad/gamepad_consumer.h" 10 #include "content/browser/gamepad/gamepad_consumer.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 TestBrowserThreadBundle browser_thread_; 73 TestBrowserThreadBundle browser_thread_;
74 WebGamepads test_data_; 74 WebGamepads test_data_;
75 75
76 DISALLOW_COPY_AND_ASSIGN(GamepadServiceTest); 76 DISALLOW_COPY_AND_ASSIGN(GamepadServiceTest);
77 }; 77 };
78 78
79 GamepadServiceTest::GamepadServiceTest() 79 GamepadServiceTest::GamepadServiceTest()
80 : browser_thread_(TestBrowserThreadBundle::IO_MAINLOOP) { 80 : browser_thread_(TestBrowserThreadBundle::IO_MAINLOOP) {
81 memset(&test_data_, 0, sizeof(test_data_)); 81 memset(&test_data_, 0, sizeof(test_data_));
82 82
83 // Set it so that we have user gesture. 83 // Must be set to zero initially to pass sanitiation
scottmg 2016/01/18 22:54:51 Zero? But .value = 1.f?
84 test_data_.items[0].buttonsLength = 1; 84 test_data_.items[0].buttonsLength = 1;
85 test_data_.items[0].buttons[0].value = 1.f; 85 test_data_.items[0].buttons[0].value = 1.f;
86 test_data_.items[0].buttons[0].pressed = true; 86 test_data_.items[0].buttons[0].pressed = true;
87 } 87 }
88 88
89 GamepadServiceTest::~GamepadServiceTest() { 89 GamepadServiceTest::~GamepadServiceTest() {
90 delete service_; 90 delete service_;
91 } 91 }
92 92
93 void GamepadServiceTest::SetUp() { 93 void GamepadServiceTest::SetUp() {
94 fetcher_ = new MockGamepadDataFetcher(test_data_); 94 fetcher_ = new MockGamepadDataFetcher(test_data_);
95 service_ = new GamepadService(scoped_ptr<GamepadDataFetcher>(fetcher_)); 95 service_ = new GamepadService(scoped_ptr<GamepadDataFetcher>(fetcher_));
96 service_->provider()->SetSanitizationEnabled(false);
96 connection_listener_.reset((new ConnectionListener)); 97 connection_listener_.reset((new ConnectionListener));
97 service_->ConsumerBecameActive(connection_listener_.get()); 98 service_->ConsumerBecameActive(connection_listener_.get());
98 } 99 }
99 100
100 void GamepadServiceTest::SetPadsConnected(bool connected) { 101 void GamepadServiceTest::SetPadsConnected(bool connected) {
101 for (int i = 0; i < kNumberOfGamepads; ++i) { 102 for (int i = 0; i < kNumberOfGamepads; ++i) {
102 test_data_.items[i].connected = connected; 103 test_data_.items[i].connected = connected;
103 } 104 }
104 fetcher_->SetTestData(test_data_); 105 fetcher_->SetTestData(test_data_);
105 } 106 }
(...skipping 18 matching lines...) Expand all
124 WaitForData(); 125 WaitForData();
125 EXPECT_EQ(0, GetConnectedCounter()); 126 EXPECT_EQ(0, GetConnectedCounter());
126 EXPECT_EQ(kNumberOfGamepads, GetDisconnectedCounter()); 127 EXPECT_EQ(kNumberOfGamepads, GetDisconnectedCounter());
127 128
128 WaitForData(); 129 WaitForData();
129 EXPECT_EQ(0, GetConnectedCounter()); 130 EXPECT_EQ(0, GetConnectedCounter());
130 EXPECT_EQ(0, GetDisconnectedCounter()); 131 EXPECT_EQ(0, GetDisconnectedCounter());
131 } 132 }
132 133
133 } // namespace content 134 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698