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

Side by Side Diff: device/bluetooth/bluetooth_adapter_win_unittest.cc

Issue 1513043002: clang/win: Let remaining chromium_code targets build with -Wextra. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 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 (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 <string> 5 #include <string>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/test/test_simple_task_runner.h" 10 #include "base/test/test_simple_task_runner.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 EXPECT_TRUE(init_callback_called_); 162 EXPECT_TRUE(init_callback_called_);
163 } 163 }
164 164
165 TEST_F(BluetoothAdapterWinTest, SingleStartDiscovery) { 165 TEST_F(BluetoothAdapterWinTest, SingleStartDiscovery) {
166 bluetooth_task_runner_->ClearPendingTasks(); 166 bluetooth_task_runner_->ClearPendingTasks();
167 CallAddDiscoverySession( 167 CallAddDiscoverySession(
168 base::Bind(&BluetoothAdapterWinTest::IncrementNumStartDiscoveryCallbacks, 168 base::Bind(&BluetoothAdapterWinTest::IncrementNumStartDiscoveryCallbacks,
169 base::Unretained(this)), 169 base::Unretained(this)),
170 DiscoverySessionErrorCallback()); 170 DiscoverySessionErrorCallback());
171 EXPECT_TRUE(ui_task_runner_->GetPendingTasks().empty()); 171 EXPECT_TRUE(ui_task_runner_->GetPendingTasks().empty());
172 EXPECT_EQ(1, bluetooth_task_runner_->GetPendingTasks().size()); 172 EXPECT_EQ(1u, bluetooth_task_runner_->GetPendingTasks().size());
173 EXPECT_FALSE(adapter_->IsDiscovering()); 173 EXPECT_FALSE(adapter_->IsDiscovering());
174 EXPECT_EQ(0, num_start_discovery_callbacks_); 174 EXPECT_EQ(0, num_start_discovery_callbacks_);
175 adapter_win_->DiscoveryStarted(true); 175 adapter_win_->DiscoveryStarted(true);
176 ui_task_runner_->RunPendingTasks(); 176 ui_task_runner_->RunPendingTasks();
177 EXPECT_TRUE(adapter_->IsDiscovering()); 177 EXPECT_TRUE(adapter_->IsDiscovering());
178 EXPECT_EQ(1, num_start_discovery_callbacks_); 178 EXPECT_EQ(1, num_start_discovery_callbacks_);
179 EXPECT_EQ(1, observer_.discovering_changed_count()); 179 EXPECT_EQ(1, observer_.discovering_changed_count());
180 } 180 }
181 181
182 TEST_F(BluetoothAdapterWinTest, SingleStartDiscoveryFailure) { 182 TEST_F(BluetoothAdapterWinTest, SingleStartDiscoveryFailure) {
(...skipping 11 matching lines...) Expand all
194 194
195 TEST_F(BluetoothAdapterWinTest, MultipleStartDiscoveries) { 195 TEST_F(BluetoothAdapterWinTest, MultipleStartDiscoveries) {
196 bluetooth_task_runner_->ClearPendingTasks(); 196 bluetooth_task_runner_->ClearPendingTasks();
197 int num_discoveries = 5; 197 int num_discoveries = 5;
198 for (int i = 0; i < num_discoveries; i++) { 198 for (int i = 0; i < num_discoveries; i++) {
199 CallAddDiscoverySession( 199 CallAddDiscoverySession(
200 base::Bind( 200 base::Bind(
201 &BluetoothAdapterWinTest::IncrementNumStartDiscoveryCallbacks, 201 &BluetoothAdapterWinTest::IncrementNumStartDiscoveryCallbacks,
202 base::Unretained(this)), 202 base::Unretained(this)),
203 DiscoverySessionErrorCallback()); 203 DiscoverySessionErrorCallback());
204 EXPECT_EQ(1, bluetooth_task_runner_->GetPendingTasks().size()); 204 EXPECT_EQ(1u, bluetooth_task_runner_->GetPendingTasks().size());
205 } 205 }
206 EXPECT_TRUE(ui_task_runner_->GetPendingTasks().empty()); 206 EXPECT_TRUE(ui_task_runner_->GetPendingTasks().empty());
207 EXPECT_FALSE(adapter_->IsDiscovering()); 207 EXPECT_FALSE(adapter_->IsDiscovering());
208 EXPECT_EQ(0, num_start_discovery_callbacks_); 208 EXPECT_EQ(0, num_start_discovery_callbacks_);
209 adapter_win_->DiscoveryStarted(true); 209 adapter_win_->DiscoveryStarted(true);
210 ui_task_runner_->RunPendingTasks(); 210 ui_task_runner_->RunPendingTasks();
211 EXPECT_TRUE(adapter_->IsDiscovering()); 211 EXPECT_TRUE(adapter_->IsDiscovering());
212 EXPECT_EQ(num_discoveries, num_start_discovery_callbacks_); 212 EXPECT_EQ(num_discoveries, num_start_discovery_callbacks_);
213 EXPECT_EQ(1, observer_.discovering_changed_count()); 213 EXPECT_EQ(1, observer_.discovering_changed_count());
214 } 214 }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 base::Unretained(this)), 310 base::Unretained(this)),
311 DiscoverySessionErrorCallback()); 311 DiscoverySessionErrorCallback());
312 EXPECT_TRUE(bluetooth_task_runner_->GetPendingTasks().empty()); 312 EXPECT_TRUE(bluetooth_task_runner_->GetPendingTasks().empty());
313 ui_task_runner_->RunPendingTasks(); 313 ui_task_runner_->RunPendingTasks();
314 EXPECT_EQ(i + 1, num_stop_discovery_callbacks_); 314 EXPECT_EQ(i + 1, num_stop_discovery_callbacks_);
315 } 315 }
316 CallRemoveDiscoverySession( 316 CallRemoveDiscoverySession(
317 base::Bind(&BluetoothAdapterWinTest::IncrementNumStopDiscoveryCallbacks, 317 base::Bind(&BluetoothAdapterWinTest::IncrementNumStopDiscoveryCallbacks,
318 base::Unretained(this)), 318 base::Unretained(this)),
319 DiscoverySessionErrorCallback()); 319 DiscoverySessionErrorCallback());
320 EXPECT_EQ(1, bluetooth_task_runner_->GetPendingTasks().size()); 320 EXPECT_EQ(1u, bluetooth_task_runner_->GetPendingTasks().size());
321 EXPECT_TRUE(adapter_->IsDiscovering()); 321 EXPECT_TRUE(adapter_->IsDiscovering());
322 adapter_win_->DiscoveryStopped(); 322 adapter_win_->DiscoveryStopped();
323 ui_task_runner_->RunPendingTasks(); 323 ui_task_runner_->RunPendingTasks();
324 EXPECT_FALSE(adapter_->IsDiscovering()); 324 EXPECT_FALSE(adapter_->IsDiscovering());
325 EXPECT_EQ(num_discoveries, num_stop_discovery_callbacks_); 325 EXPECT_EQ(num_discoveries, num_stop_discovery_callbacks_);
326 EXPECT_EQ(2, observer_.discovering_changed_count()); 326 EXPECT_EQ(2, observer_.discovering_changed_count());
327 } 327 }
328 328
329 TEST_F(BluetoothAdapterWinTest, 329 TEST_F(BluetoothAdapterWinTest,
330 StartDiscoveryAndStartDiscoveryAndStopDiscoveries) { 330 StartDiscoveryAndStartDiscoveryAndStopDiscoveries) {
(...skipping 10 matching lines...) Expand all
341 bluetooth_task_runner_->ClearPendingTasks(); 341 bluetooth_task_runner_->ClearPendingTasks();
342 CallRemoveDiscoverySession( 342 CallRemoveDiscoverySession(
343 base::Bind(&BluetoothAdapterWinTest::IncrementNumStopDiscoveryCallbacks, 343 base::Bind(&BluetoothAdapterWinTest::IncrementNumStopDiscoveryCallbacks,
344 base::Unretained(this)), 344 base::Unretained(this)),
345 DiscoverySessionErrorCallback()); 345 DiscoverySessionErrorCallback());
346 EXPECT_TRUE(bluetooth_task_runner_->GetPendingTasks().empty()); 346 EXPECT_TRUE(bluetooth_task_runner_->GetPendingTasks().empty());
347 CallRemoveDiscoverySession( 347 CallRemoveDiscoverySession(
348 base::Bind(&BluetoothAdapterWinTest::IncrementNumStopDiscoveryCallbacks, 348 base::Bind(&BluetoothAdapterWinTest::IncrementNumStopDiscoveryCallbacks,
349 base::Unretained(this)), 349 base::Unretained(this)),
350 DiscoverySessionErrorCallback()); 350 DiscoverySessionErrorCallback());
351 EXPECT_EQ(1, bluetooth_task_runner_->GetPendingTasks().size()); 351 EXPECT_EQ(1u, bluetooth_task_runner_->GetPendingTasks().size());
352 } 352 }
353 353
354 TEST_F(BluetoothAdapterWinTest, 354 TEST_F(BluetoothAdapterWinTest,
355 StartDiscoveryAndStopDiscoveryAndStartDiscovery) { 355 StartDiscoveryAndStopDiscoveryAndStartDiscovery) {
356 CallAddDiscoverySession(base::Closure(), DiscoverySessionErrorCallback()); 356 CallAddDiscoverySession(base::Closure(), DiscoverySessionErrorCallback());
357 adapter_win_->DiscoveryStarted(true); 357 adapter_win_->DiscoveryStarted(true);
358 EXPECT_TRUE(adapter_->IsDiscovering()); 358 EXPECT_TRUE(adapter_->IsDiscovering());
359 CallRemoveDiscoverySession(base::Closure(), DiscoverySessionErrorCallback()); 359 CallRemoveDiscoverySession(base::Closure(), DiscoverySessionErrorCallback());
360 adapter_win_->DiscoveryStopped(); 360 adapter_win_->DiscoveryStopped();
361 EXPECT_FALSE(adapter_->IsDiscovering()); 361 EXPECT_FALSE(adapter_->IsDiscovering());
362 CallAddDiscoverySession(base::Closure(), DiscoverySessionErrorCallback()); 362 CallAddDiscoverySession(base::Closure(), DiscoverySessionErrorCallback());
363 adapter_win_->DiscoveryStarted(true); 363 adapter_win_->DiscoveryStarted(true);
364 EXPECT_TRUE(adapter_->IsDiscovering()); 364 EXPECT_TRUE(adapter_->IsDiscovering());
365 } 365 }
366 366
367 TEST_F(BluetoothAdapterWinTest, StartDiscoveryBeforeDiscoveryStopped) { 367 TEST_F(BluetoothAdapterWinTest, StartDiscoveryBeforeDiscoveryStopped) {
368 CallAddDiscoverySession(base::Closure(), DiscoverySessionErrorCallback()); 368 CallAddDiscoverySession(base::Closure(), DiscoverySessionErrorCallback());
369 adapter_win_->DiscoveryStarted(true); 369 adapter_win_->DiscoveryStarted(true);
370 CallRemoveDiscoverySession(base::Closure(), DiscoverySessionErrorCallback()); 370 CallRemoveDiscoverySession(base::Closure(), DiscoverySessionErrorCallback());
371 CallAddDiscoverySession(base::Closure(), DiscoverySessionErrorCallback()); 371 CallAddDiscoverySession(base::Closure(), DiscoverySessionErrorCallback());
372 bluetooth_task_runner_->ClearPendingTasks(); 372 bluetooth_task_runner_->ClearPendingTasks();
373 adapter_win_->DiscoveryStopped(); 373 adapter_win_->DiscoveryStopped();
374 EXPECT_EQ(1, bluetooth_task_runner_->GetPendingTasks().size()); 374 EXPECT_EQ(1u, bluetooth_task_runner_->GetPendingTasks().size());
375 } 375 }
376 376
377 TEST_F(BluetoothAdapterWinTest, StopDiscoveryWithoutStartDiscovery) { 377 TEST_F(BluetoothAdapterWinTest, StopDiscoveryWithoutStartDiscovery) {
378 CallRemoveDiscoverySession( 378 CallRemoveDiscoverySession(
379 base::Closure(), 379 base::Closure(),
380 base::Bind( 380 base::Bind(
381 &BluetoothAdapterWinTest::IncrementNumStopDiscoveryErrorCallbacks, 381 &BluetoothAdapterWinTest::IncrementNumStopDiscoveryErrorCallbacks,
382 base::Unretained(this))); 382 base::Unretained(this)));
383 EXPECT_EQ(1, num_stop_discovery_error_callbacks_); 383 EXPECT_EQ(1, num_stop_discovery_error_callbacks_);
384 } 384 }
385 385
386 TEST_F(BluetoothAdapterWinTest, StopDiscoveryBeforeDiscoveryStarted) { 386 TEST_F(BluetoothAdapterWinTest, StopDiscoveryBeforeDiscoveryStarted) {
387 CallAddDiscoverySession(base::Closure(), DiscoverySessionErrorCallback()); 387 CallAddDiscoverySession(base::Closure(), DiscoverySessionErrorCallback());
388 CallRemoveDiscoverySession(base::Closure(), DiscoverySessionErrorCallback()); 388 CallRemoveDiscoverySession(base::Closure(), DiscoverySessionErrorCallback());
389 bluetooth_task_runner_->ClearPendingTasks(); 389 bluetooth_task_runner_->ClearPendingTasks();
390 adapter_win_->DiscoveryStarted(true); 390 adapter_win_->DiscoveryStarted(true);
391 EXPECT_EQ(1, bluetooth_task_runner_->GetPendingTasks().size()); 391 EXPECT_EQ(1u, bluetooth_task_runner_->GetPendingTasks().size());
392 } 392 }
393 393
394 TEST_F(BluetoothAdapterWinTest, StartAndStopBeforeDiscoveryStarted) { 394 TEST_F(BluetoothAdapterWinTest, StartAndStopBeforeDiscoveryStarted) {
395 int num_expected_start_discoveries = 3; 395 int num_expected_start_discoveries = 3;
396 int num_expected_stop_discoveries = 2; 396 int num_expected_stop_discoveries = 2;
397 for (int i = 0; i < num_expected_start_discoveries; i++) { 397 for (int i = 0; i < num_expected_start_discoveries; i++) {
398 CallAddDiscoverySession( 398 CallAddDiscoverySession(
399 base::Bind( 399 base::Bind(
400 &BluetoothAdapterWinTest::IncrementNumStartDiscoveryCallbacks, 400 &BluetoothAdapterWinTest::IncrementNumStartDiscoveryCallbacks,
401 base::Unretained(this)), 401 base::Unretained(this)),
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 // Remove a service 502 // Remove a service
503 laptop_state->service_record_states.clear(); 503 laptop_state->service_record_states.clear();
504 observer_.Reset(); 504 observer_.Reset();
505 adapter_win_->DevicesPolled(devices); 505 adapter_win_->DevicesPolled(devices);
506 EXPECT_EQ(0, observer_.device_added_count()); 506 EXPECT_EQ(0, observer_.device_added_count());
507 EXPECT_EQ(0, observer_.device_removed_count()); 507 EXPECT_EQ(0, observer_.device_removed_count());
508 EXPECT_EQ(1, observer_.device_changed_count()); 508 EXPECT_EQ(1, observer_.device_changed_count());
509 } 509 }
510 510
511 } // namespace device 511 } // namespace device
OLDNEW
« no previous file with comments | « components/storage_monitor/storage_monitor_win_unittest.cc ('k') | device/bluetooth/bluetooth_device_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698