diff options
author | haruki@chromium.org <haruki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-14 04:58:56 +0000 |
---|---|---|
committer | haruki@chromium.org <haruki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-14 04:58:56 +0000 |
commit | cc70f5017d56dee38acfaebd5f7a24c8af830e07 (patch) | |
tree | 778a74caab9e64a025d660e53a71e8b445980136 /chromeos/dbus/fake_cros_disks_client.cc | |
parent | 301528546d702e1d3adf2cf3ba178b556d0bb9a2 (diff) | |
download | chromium_src-cc70f5017d56dee38acfaebd5f7a24c8af830e07.zip chromium_src-cc70f5017d56dee38acfaebd5f7a24c8af830e07.tar.gz chromium_src-cc70f5017d56dee38acfaebd5f7a24c8af830e07.tar.bz2 |
Use MockDBusThreadManagerWithoutGMock for DiskMountManagerTest
Adding FakeCrosDisksClient some utilities to inspect methods calls.
BUG=223061
TEST=trybots
R=satorux@chromium.org
Review URL: https://codereview.chromium.org/14565003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@199905 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos/dbus/fake_cros_disks_client.cc')
-rw-r--r-- | chromeos/dbus/fake_cros_disks_client.cc | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/chromeos/dbus/fake_cros_disks_client.cc b/chromeos/dbus/fake_cros_disks_client.cc index 03d9444..fe5873d 100644 --- a/chromeos/dbus/fake_cros_disks_client.cc +++ b/chromeos/dbus/fake_cros_disks_client.cc @@ -4,9 +4,16 @@ #include "chromeos/dbus/fake_cros_disks_client.h" +#include "base/bind.h" +#include "base/message_loop.h" + namespace chromeos { -FakeCrosDisksClient::FakeCrosDisksClient() { +FakeCrosDisksClient::FakeCrosDisksClient() + : unmount_call_count_(0), + unmount_success_(true), + format_device_call_count_(0), + format_device_success_(true) { } FakeCrosDisksClient::~FakeCrosDisksClient() {} @@ -23,6 +30,18 @@ void FakeCrosDisksClient::Unmount(const std::string& device_path, UnmountOptions options, const UnmountCallback& callback, const UnmountCallback& error_callback) { + DCHECK(!callback.is_null()); + DCHECK(!error_callback.is_null()); + + unmount_call_count_++; + last_unmount_device_path_ = device_path; + last_unmount_options_ = options; + base::MessageLoopProxy::current()->PostTask( + FROM_HERE, + base::Bind(unmount_success_ ? callback : error_callback, + device_path)); + if(!unmount_listener_.is_null()) + unmount_listener_.Run(); } void FakeCrosDisksClient::EnumerateAutoMountableDevices( @@ -34,6 +53,21 @@ void FakeCrosDisksClient::FormatDevice(const std::string& device_path, const std::string& filesystem, const FormatDeviceCallback& callback, const ErrorCallback& error_callback) { + DCHECK(!callback.is_null()); + DCHECK(!error_callback.is_null()); + + format_device_call_count_++; + last_format_device_device_path_ = device_path; + last_format_device_filesystem_ = filesystem; + if (format_device_success_) { + base::MessageLoopProxy::current()->PostTask( + FROM_HERE, + base::Bind(callback, device_path, true)); + } else { + base::MessageLoopProxy::current()->PostTask( + FROM_HERE, + base::Bind(error_callback)); + } } void FakeCrosDisksClient::GetDeviceProperties( |