summaryrefslogtreecommitdiffstats
path: root/chromeos
diff options
context:
space:
mode:
authorkeybuk@chromium.org <keybuk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-18 03:19:06 +0000
committerkeybuk@chromium.org <keybuk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-18 03:19:06 +0000
commitfa0e3ff90295784879f70ffa066e5f3b9bc9fa23 (patch)
tree5975c5a1a5ea6bdaff1b89fc936d68fbc191ca40 /chromeos
parentfb246af3f30a1775ffbcf4bdcf6bb347cd5382d1 (diff)
downloadchromium_src-fa0e3ff90295784879f70ffa066e5f3b9bc9fa23.zip
chromium_src-fa0e3ff90295784879f70ffa066e5f3b9bc9fa23.tar.gz
chromium_src-fa0e3ff90295784879f70ffa066e5f3b9bc9fa23.tar.bz2
bluetooth: Improve testability
Make a bunch of changes to the bluetooth code to improve its testability: - BluetoothAdapter and BluetoothDevice base observer and delegate classes made public, allows a test to static cast the pointer and call those methods as if it were the dbus client. - Add MockBluetoothAdapter::Observer and MockBluetoothDevice::Observer classes; these can be used by tests to check BluetoothAdapter and BluetoothDevice call observer methods at the correct time, with the correct arguments. - Add MockBluetooth*Client::Properties classes; these mock out the Get(), GetAll() and Set() methods so a test can verify whether or not they're called. Tests can also use MockBluetooth*Client::GetProperties() to return one of these mock classes constructed statically in the test, using ReplaceValue() on each property to set values. BUG=none TEST=can write a unit test Change-Id: I9eaeb6412de891f9b1b3cdaae66d32dfecbac8c9 Review URL: https://chromiumcodereview.appspot.com/10831360 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152234 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos')
-rw-r--r--chromeos/dbus/mock_bluetooth_adapter_client.cc6
-rw-r--r--chromeos/dbus/mock_bluetooth_adapter_client.h15
-rw-r--r--chromeos/dbus/mock_bluetooth_device_client.cc6
-rw-r--r--chromeos/dbus/mock_bluetooth_device_client.h15
-rw-r--r--chromeos/dbus/mock_bluetooth_input_client.cc6
-rw-r--r--chromeos/dbus/mock_bluetooth_input_client.h15
-rw-r--r--chromeos/dbus/mock_bluetooth_manager_client.cc6
-rw-r--r--chromeos/dbus/mock_bluetooth_manager_client.h15
-rw-r--r--chromeos/dbus/mock_bluetooth_node_client.cc6
-rw-r--r--chromeos/dbus/mock_bluetooth_node_client.h15
10 files changed, 105 insertions, 0 deletions
diff --git a/chromeos/dbus/mock_bluetooth_adapter_client.cc b/chromeos/dbus/mock_bluetooth_adapter_client.cc
index bef773c..73b3d54 100644
--- a/chromeos/dbus/mock_bluetooth_adapter_client.cc
+++ b/chromeos/dbus/mock_bluetooth_adapter_client.cc
@@ -6,6 +6,12 @@
namespace chromeos {
+MockBluetoothAdapterClient::Properties::Properties()
+ : BluetoothAdapterClient::Properties::Properties(
+ NULL, PropertyChangedCallback()) {}
+
+MockBluetoothAdapterClient::Properties::~Properties() {}
+
MockBluetoothAdapterClient::MockBluetoothAdapterClient() {}
MockBluetoothAdapterClient::~MockBluetoothAdapterClient() {}
diff --git a/chromeos/dbus/mock_bluetooth_adapter_client.h b/chromeos/dbus/mock_bluetooth_adapter_client.h
index a823945..c1d5f1e 100644
--- a/chromeos/dbus/mock_bluetooth_adapter_client.h
+++ b/chromeos/dbus/mock_bluetooth_adapter_client.h
@@ -14,6 +14,21 @@ namespace chromeos {
class MockBluetoothAdapterClient : public BluetoothAdapterClient {
public:
+ struct Properties : public BluetoothAdapterClient::Properties {
+ Properties();
+ virtual ~Properties();
+
+ MOCK_METHOD0(ConnectSignals, void());
+
+ MOCK_METHOD2(Get, void(dbus::PropertyBase* property,
+ dbus::PropertySet::GetCallback callback));
+ MOCK_METHOD0(GetAll, void());
+ MOCK_METHOD2(Set, void(dbus::PropertyBase* property,
+ dbus::PropertySet::SetCallback callback));
+
+ MOCK_METHOD1(ChangedReceived, void(dbus::Signal*));
+ };
+
MockBluetoothAdapterClient();
virtual ~MockBluetoothAdapterClient();
diff --git a/chromeos/dbus/mock_bluetooth_device_client.cc b/chromeos/dbus/mock_bluetooth_device_client.cc
index 75b5c44..f595daa 100644
--- a/chromeos/dbus/mock_bluetooth_device_client.cc
+++ b/chromeos/dbus/mock_bluetooth_device_client.cc
@@ -6,6 +6,12 @@
namespace chromeos {
+MockBluetoothDeviceClient::Properties::Properties()
+ : BluetoothDeviceClient::Properties::Properties(
+ NULL, PropertyChangedCallback()) {}
+
+MockBluetoothDeviceClient::Properties::~Properties() {}
+
MockBluetoothDeviceClient::MockBluetoothDeviceClient() {}
MockBluetoothDeviceClient::~MockBluetoothDeviceClient() {}
diff --git a/chromeos/dbus/mock_bluetooth_device_client.h b/chromeos/dbus/mock_bluetooth_device_client.h
index 35050e2..94cb8c4 100644
--- a/chromeos/dbus/mock_bluetooth_device_client.h
+++ b/chromeos/dbus/mock_bluetooth_device_client.h
@@ -14,6 +14,21 @@ namespace chromeos {
class MockBluetoothDeviceClient : public BluetoothDeviceClient {
public:
+ struct Properties : public BluetoothDeviceClient::Properties {
+ Properties();
+ virtual ~Properties();
+
+ MOCK_METHOD0(ConnectSignals, void());
+
+ MOCK_METHOD2(Get, void(dbus::PropertyBase* property,
+ dbus::PropertySet::GetCallback callback));
+ MOCK_METHOD0(GetAll, void());
+ MOCK_METHOD2(Set, void(dbus::PropertyBase* property,
+ dbus::PropertySet::SetCallback callback));
+
+ MOCK_METHOD1(ChangedReceived, void(dbus::Signal*));
+ };
+
MockBluetoothDeviceClient();
virtual ~MockBluetoothDeviceClient();
diff --git a/chromeos/dbus/mock_bluetooth_input_client.cc b/chromeos/dbus/mock_bluetooth_input_client.cc
index b73ef1e..54cc0a0 100644
--- a/chromeos/dbus/mock_bluetooth_input_client.cc
+++ b/chromeos/dbus/mock_bluetooth_input_client.cc
@@ -6,6 +6,12 @@
namespace chromeos {
+MockBluetoothInputClient::Properties::Properties()
+ : BluetoothInputClient::Properties::Properties(
+ NULL, PropertyChangedCallback()) {}
+
+MockBluetoothInputClient::Properties::~Properties() {}
+
MockBluetoothInputClient::MockBluetoothInputClient() {}
MockBluetoothInputClient::~MockBluetoothInputClient() {}
diff --git a/chromeos/dbus/mock_bluetooth_input_client.h b/chromeos/dbus/mock_bluetooth_input_client.h
index afa438c..19bfaee 100644
--- a/chromeos/dbus/mock_bluetooth_input_client.h
+++ b/chromeos/dbus/mock_bluetooth_input_client.h
@@ -14,6 +14,21 @@ namespace chromeos {
class MockBluetoothInputClient : public BluetoothInputClient {
public:
+ struct Properties : public BluetoothInputClient::Properties {
+ Properties();
+ virtual ~Properties();
+
+ MOCK_METHOD0(ConnectSignals, void());
+
+ MOCK_METHOD2(Get, void(dbus::PropertyBase* property,
+ dbus::PropertySet::GetCallback callback));
+ MOCK_METHOD0(GetAll, void());
+ MOCK_METHOD2(Set, void(dbus::PropertyBase* property,
+ dbus::PropertySet::SetCallback callback));
+
+ MOCK_METHOD1(ChangedReceived, void(dbus::Signal*));
+ };
+
MockBluetoothInputClient();
virtual ~MockBluetoothInputClient();
diff --git a/chromeos/dbus/mock_bluetooth_manager_client.cc b/chromeos/dbus/mock_bluetooth_manager_client.cc
index 9fd6f93..3b31d72 100644
--- a/chromeos/dbus/mock_bluetooth_manager_client.cc
+++ b/chromeos/dbus/mock_bluetooth_manager_client.cc
@@ -6,6 +6,12 @@
namespace chromeos {
+MockBluetoothManagerClient::Properties::Properties()
+ : BluetoothManagerClient::Properties::Properties(
+ NULL, PropertyChangedCallback()) {}
+
+MockBluetoothManagerClient::Properties::~Properties() {}
+
MockBluetoothManagerClient::MockBluetoothManagerClient() {}
MockBluetoothManagerClient::~MockBluetoothManagerClient() {}
diff --git a/chromeos/dbus/mock_bluetooth_manager_client.h b/chromeos/dbus/mock_bluetooth_manager_client.h
index 9485e24..b6175c2 100644
--- a/chromeos/dbus/mock_bluetooth_manager_client.h
+++ b/chromeos/dbus/mock_bluetooth_manager_client.h
@@ -14,6 +14,21 @@ namespace chromeos {
class MockBluetoothManagerClient : public BluetoothManagerClient {
public:
+ struct Properties : public BluetoothManagerClient::Properties {
+ Properties();
+ virtual ~Properties();
+
+ MOCK_METHOD0(ConnectSignals, void());
+
+ MOCK_METHOD2(Get, void(dbus::PropertyBase* property,
+ dbus::PropertySet::GetCallback callback));
+ MOCK_METHOD0(GetAll, void());
+ MOCK_METHOD2(Set, void(dbus::PropertyBase* property,
+ dbus::PropertySet::SetCallback callback));
+
+ MOCK_METHOD1(ChangedReceived, void(dbus::Signal*));
+ };
+
MockBluetoothManagerClient();
virtual ~MockBluetoothManagerClient();
diff --git a/chromeos/dbus/mock_bluetooth_node_client.cc b/chromeos/dbus/mock_bluetooth_node_client.cc
index fddd878..9c5efa9 100644
--- a/chromeos/dbus/mock_bluetooth_node_client.cc
+++ b/chromeos/dbus/mock_bluetooth_node_client.cc
@@ -6,6 +6,12 @@
namespace chromeos {
+MockBluetoothNodeClient::Properties::Properties()
+ : BluetoothNodeClient::Properties::Properties(
+ NULL, PropertyChangedCallback()) {}
+
+MockBluetoothNodeClient::Properties::~Properties() {}
+
MockBluetoothNodeClient::MockBluetoothNodeClient() {}
MockBluetoothNodeClient::~MockBluetoothNodeClient() {}
diff --git a/chromeos/dbus/mock_bluetooth_node_client.h b/chromeos/dbus/mock_bluetooth_node_client.h
index 78b1497..dd0b591 100644
--- a/chromeos/dbus/mock_bluetooth_node_client.h
+++ b/chromeos/dbus/mock_bluetooth_node_client.h
@@ -14,6 +14,21 @@ namespace chromeos {
class MockBluetoothNodeClient : public BluetoothNodeClient {
public:
+ struct Properties : public BluetoothNodeClient::Properties {
+ Properties();
+ virtual ~Properties();
+
+ MOCK_METHOD0(ConnectSignals, void());
+
+ MOCK_METHOD2(Get, void(dbus::PropertyBase* property,
+ dbus::PropertySet::GetCallback callback));
+ MOCK_METHOD0(GetAll, void());
+ MOCK_METHOD2(Set, void(dbus::PropertyBase* property,
+ dbus::PropertySet::SetCallback callback));
+
+ MOCK_METHOD1(ChangedReceived, void(dbus::Signal*));
+ };
+
MockBluetoothNodeClient();
virtual ~MockBluetoothNodeClient();