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

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

Issue 1124883004: Submission for C++ Readability (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/memory/scoped_vector.h" 5 #include "base/memory/scoped_vector.h"
6 #include "base/message_loop/message_loop.h" 6 #include "base/message_loop/message_loop.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chromeos/dbus/dbus_thread_manager.h" 9 #include "chromeos/dbus/dbus_thread_manager.h"
10 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" 10 #include "chromeos/dbus/fake_bluetooth_adapter_client.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 int request_passkey_count_; 132 int request_passkey_count_;
133 int display_pincode_count_; 133 int display_pincode_count_;
134 int display_passkey_count_; 134 int display_passkey_count_;
135 int keys_entered_count_; 135 int keys_entered_count_;
136 int confirm_passkey_count_; 136 int confirm_passkey_count_;
137 int authorize_pairing_count_; 137 int authorize_pairing_count_;
138 uint32 last_passkey_; 138 uint32 last_passkey_;
139 uint32 last_entered_; 139 uint32 last_entered_;
140 std::string last_pincode_; 140 std::string last_pincode_;
141 141
142 private: 142 private:
omoikane 2015/05/22 23:55:28 These lines should be shifted 1 space left. http:/
Marie Janssen 2015/06/18 21:08:35 Done.
143 // Some tests use a message loop since background processing is simulated; 143 // Some tests use a message loop since background processing is simulated;
144 // break out of those loops. 144 // break out of those loops.
145 void QuitMessageLoop() { 145 void QuitMessageLoop() {
146 if (base::MessageLoop::current() && 146 if (base::MessageLoop::current() &&
147 base::MessageLoop::current()->is_running()) 147 base::MessageLoop::current()->is_running())
148 base::MessageLoop::current()->Quit(); 148 base::MessageLoop::current()->Quit();
149 } 149 }
150 }; 150 };
151 151
152 class BluetoothChromeOSTest : public testing::Test { 152 class BluetoothChromeOSTest : public testing::Test {
(...skipping 1490 matching lines...) Expand 10 before | Expand all | Expand 10 after
1643 EXPECT_EQ(0, error_callback_count_); 1643 EXPECT_EQ(0, error_callback_count_);
1644 callback_count_ = 0; 1644 callback_count_ = 0;
1645 1645
1646 ASSERT_TRUE(adapter_->IsPowered()); 1646 ASSERT_TRUE(adapter_->IsPowered());
1647 ASSERT_TRUE(adapter_->IsDiscovering()); 1647 ASSERT_TRUE(adapter_->IsDiscovering());
1648 ASSERT_EQ((size_t)1, discovery_sessions_.size()); 1648 ASSERT_EQ((size_t)1, discovery_sessions_.size());
1649 ASSERT_TRUE(discovery_sessions_[0]->IsActive()); 1649 ASSERT_TRUE(discovery_sessions_[0]->IsActive());
1650 EXPECT_EQ(1, observer.discovering_changed_count()); 1650 EXPECT_EQ(1, observer.discovering_changed_count());
1651 observer.Reset(); 1651 observer.Reset();
1652 1652
1653 auto nullInstance = scoped_ptr<BluetoothDiscoveryFilter>(); 1653 auto nullInstance = scoped_ptr<BluetoothDiscoveryFilter>();
omoikane 2015/05/22 23:55:28 This variable should be renamed to follow naming c
Marie Janssen 2015/06/18 21:08:35 Done.
1654 nullInstance.reset(); 1654 nullInstance.reset();
1655 ASSERT_EQ(discovery_sessions_[0]->GetDiscoveryFilter(), nullInstance.get()); 1655 ASSERT_EQ(discovery_sessions_[0]->GetDiscoveryFilter(), nullInstance.get());
1656 1656
1657 auto filter = fake_bluetooth_adapter_client_->GetDiscoveryFilter(); 1657 auto filter = fake_bluetooth_adapter_client_->GetDiscoveryFilter();
1658 EXPECT_EQ(nullptr, filter); 1658 EXPECT_EQ(nullptr, filter);
1659 1659
1660 BluetoothDiscoveryFilter* df = new BluetoothDiscoveryFilter( 1660 BluetoothDiscoveryFilter* df = new BluetoothDiscoveryFilter(
1661 BluetoothDiscoveryFilter::Transport::TRANSPORT_LE); 1661 BluetoothDiscoveryFilter::Transport::TRANSPORT_LE);
1662 df->SetRSSI(-60); 1662 df->SetRSSI(-60);
1663 df->AddUUID(BluetoothUUID("1000")); 1663 df->AddUUID(BluetoothUUID("1000"));
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after
2566 // One call for DisplayPasskey() and one for KeysEntered(). 2566 // One call for DisplayPasskey() and one for KeysEntered().
2567 EXPECT_EQ(2, pairing_delegate.call_count_); 2567 EXPECT_EQ(2, pairing_delegate.call_count_);
2568 EXPECT_EQ(1, pairing_delegate.display_passkey_count_); 2568 EXPECT_EQ(1, pairing_delegate.display_passkey_count_);
2569 EXPECT_EQ(123456U, pairing_delegate.last_passkey_); 2569 EXPECT_EQ(123456U, pairing_delegate.last_passkey_);
2570 EXPECT_EQ(1, pairing_delegate.keys_entered_count_); 2570 EXPECT_EQ(1, pairing_delegate.keys_entered_count_);
2571 EXPECT_EQ(0U, pairing_delegate.last_entered_); 2571 EXPECT_EQ(0U, pairing_delegate.last_entered_);
2572 2572
2573 EXPECT_TRUE(device->IsConnecting()); 2573 EXPECT_TRUE(device->IsConnecting());
2574 2574
2575 // One call to KeysEntered() for each key, including [enter]. 2575 // One call to KeysEntered() for each key, including [enter].
2576 for(int i = 1; i <= 7; ++i) { 2576 for(int i = 1; i <= 7; ++i) {
omoikane 2015/05/22 23:55:28 Need extra space after "for".
Marie Janssen 2015/06/18 21:08:35 Done.
2577 message_loop_.Run(); 2577 message_loop_.Run();
2578 2578
2579 EXPECT_EQ(2 + i, pairing_delegate.call_count_); 2579 EXPECT_EQ(2 + i, pairing_delegate.call_count_);
2580 EXPECT_EQ(1 + i, pairing_delegate.keys_entered_count_); 2580 EXPECT_EQ(1 + i, pairing_delegate.keys_entered_count_);
2581 EXPECT_EQ(static_cast<uint32_t>(i), pairing_delegate.last_entered_); 2581 EXPECT_EQ(static_cast<uint32_t>(i), pairing_delegate.last_entered_);
2582 } 2582 }
2583 2583
2584 message_loop_.Run(); 2584 message_loop_.Run();
2585 2585
2586 // 8 KeysEntered notifications (0 to 7, inclusive) and one aditional call for 2586 // 8 KeysEntered notifications (0 to 7, inclusive) and one aditional call for
(...skipping 1447 matching lines...) Expand 10 before | Expand all | Expand 10 after
4034 adapter_->Shutdown(); 4034 adapter_->Shutdown();
4035 adapter_chrome_os->OnStopDiscoveryError(GetErrorCallback(), "", ""); 4035 adapter_chrome_os->OnStopDiscoveryError(GetErrorCallback(), "", "");
4036 4036
4037 // 1 error reported to RemoveDiscoverySession because of OnStopDiscoveryError, 4037 // 1 error reported to RemoveDiscoverySession because of OnStopDiscoveryError,
4038 // and kNumberOfDiscoverySessions errors queued with AddDiscoverySession. 4038 // and kNumberOfDiscoverySessions errors queued with AddDiscoverySession.
4039 EXPECT_EQ(0, callback_count_); 4039 EXPECT_EQ(0, callback_count_);
4040 EXPECT_EQ(1 + kNumberOfDiscoverySessions, error_callback_count_); 4040 EXPECT_EQ(1 + kNumberOfDiscoverySessions, error_callback_count_);
4041 } 4041 }
4042 4042
4043 } // namespace chromeos 4043 } // namespace chromeos
4044
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698