Chromium Code Reviews| OLD | NEW |
|---|---|
| 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.h> | 5 #include <string.h> |
| 6 | 6 |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/extensions/extension_apitest.h" | 9 #include "chrome/browser/extensions/extension_apitest.h" |
| 10 #include "chrome/browser/extensions/extension_function_test_utils.h" | 10 #include "chrome/browser/extensions/extension_function_test_utils.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 EXPECT_CALL(*mock_adapter_, IsPowered()) | 125 EXPECT_CALL(*mock_adapter_, IsPowered()) |
| 126 .WillOnce(testing::Return(true)); | 126 .WillOnce(testing::Return(true)); |
| 127 EXPECT_CALL(*mock_adapter_, IsDiscovering()) | 127 EXPECT_CALL(*mock_adapter_, IsDiscovering()) |
| 128 .WillOnce(testing::Return(false)); | 128 .WillOnce(testing::Return(false)); |
| 129 | 129 |
| 130 scoped_refptr<api::BluetoothGetAdapterStateFunction> get_adapter_state; | 130 scoped_refptr<api::BluetoothGetAdapterStateFunction> get_adapter_state; |
| 131 get_adapter_state = setupFunction(new api::BluetoothGetAdapterStateFunction); | 131 get_adapter_state = setupFunction(new api::BluetoothGetAdapterStateFunction); |
| 132 | 132 |
| 133 scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( | 133 scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( |
| 134 get_adapter_state.get(), "[]", browser())); | 134 get_adapter_state.get(), "[]", browser())); |
| 135 ASSERT_TRUE(result.get() != NULL); | 135 ASSERT_TRUE(result.get() != nullptr); |
| 136 api::bluetooth::AdapterState state; | 136 api::bluetooth::AdapterState state; |
| 137 ASSERT_TRUE(api::bluetooth::AdapterState::Populate(*result, &state)); | 137 ASSERT_TRUE(api::bluetooth::AdapterState::Populate(*result, &state)); |
| 138 | 138 |
| 139 EXPECT_FALSE(state.available); | 139 EXPECT_FALSE(state.available); |
| 140 EXPECT_TRUE(state.powered); | 140 EXPECT_TRUE(state.powered); |
| 141 EXPECT_FALSE(state.discovering); | 141 EXPECT_FALSE(state.discovering); |
| 142 EXPECT_EQ(kName, state.name); | 142 EXPECT_EQ(kName, state.name); |
| 143 EXPECT_EQ(kAdapterAddress, state.address); | 143 EXPECT_EQ(kAdapterAddress, state.address); |
| 144 } | 144 } |
| 145 | 145 |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 382 } | 382 } |
| 383 | 383 |
| 384 IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetDevice) { | 384 IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetDevice) { |
| 385 ResultCatcher catcher; | 385 ResultCatcher catcher; |
| 386 catcher.RestrictToBrowserContext(browser()->profile()); | 386 catcher.RestrictToBrowserContext(browser()->profile()); |
| 387 | 387 |
| 388 EXPECT_CALL(*mock_adapter_, GetDevice(device1_->GetAddress())) | 388 EXPECT_CALL(*mock_adapter_, GetDevice(device1_->GetAddress())) |
| 389 .WillOnce(testing::Return(device1_.get())); | 389 .WillOnce(testing::Return(device1_.get())); |
| 390 EXPECT_CALL(*mock_adapter_, GetDevice(device2_->GetAddress())) | 390 EXPECT_CALL(*mock_adapter_, GetDevice(device2_->GetAddress())) |
| 391 .Times(1) | 391 .Times(1) |
| 392 .WillRepeatedly(testing::Return(static_cast<BluetoothDevice*>(NULL))); | 392 .WillRepeatedly(testing::Return(static_cast<BluetoothDevice*>(nullptr))); |
|
Nico
2014/09/25 05:57:19
Hmm, is this static_cast still needed with nullptr
Sam McNally
2014/09/25 07:42:38
Clang on Linux and MSVC are both happy without the
Nico
2014/09/25 19:33:41
Hm, maybe we can contribute a patch to clang-moder
| |
| 393 | 393 |
| 394 // Load and wait for setup | 394 // Load and wait for setup |
| 395 ExtensionTestMessageListener listener("ready", true); | 395 ExtensionTestMessageListener listener("ready", true); |
| 396 ASSERT_TRUE( | 396 ASSERT_TRUE( |
| 397 LoadExtension(test_data_dir_.AppendASCII("bluetooth/get_device"))); | 397 LoadExtension(test_data_dir_.AppendASCII("bluetooth/get_device"))); |
| 398 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 398 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
| 399 | 399 |
| 400 listener.Reply("go"); | 400 listener.Reply("go"); |
| 401 | 401 |
| 402 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 402 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 453 // Load and wait for setup | 453 // Load and wait for setup |
| 454 ExtensionTestMessageListener listener("ready", true); | 454 ExtensionTestMessageListener listener("ready", true); |
| 455 ASSERT_TRUE( | 455 ASSERT_TRUE( |
| 456 LoadExtension(test_data_dir_.AppendASCII("bluetooth/device_info"))); | 456 LoadExtension(test_data_dir_.AppendASCII("bluetooth/device_info"))); |
| 457 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 457 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
| 458 | 458 |
| 459 listener.Reply("go"); | 459 listener.Reply("go"); |
| 460 | 460 |
| 461 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 461 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 462 } | 462 } |
| OLD | NEW |