shill: wimax: Replace TestProxyFactory variants with MockProxyFactory.
This CL reduces the number of TestProxyFactory variants in WiMAX unit
tests as follows:
- Use MockProxyFactor with EXPECT_CALL to mimic
TestProxyFactory::Create*Proxy methods.
- Check arguments passed to MockProxyFactory::Create*Proxy() via
EXPECT_CALL.
BUG=chromium:338623
TEST=`USE='wimax' FEATURES=test emerge-{x86,amd64,arm}-generic shill`
Change-Id: Ic3d4db6b7cb54f171e2dda3c48f36cb9cf193c1b
Reviewed-on: https://chromium-review.googlesource.com/184435
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
diff --git a/wimax_unittest.cc b/wimax_unittest.cc
index 7c89ed8..e447e6e 100644
--- a/wimax_unittest.cc
+++ b/wimax_unittest.cc
@@ -6,20 +6,17 @@
#include <string>
-#include <base/stringprintf.h>
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
-
#include "shill/event_dispatcher.h"
#include "shill/mock_dhcp_config.h"
#include "shill/mock_dhcp_provider.h"
#include "shill/mock_manager.h"
#include "shill/mock_metrics.h"
+#include "shill/mock_proxy_factory.h"
#include "shill/mock_wimax_device_proxy.h"
#include "shill/mock_wimax_provider.h"
#include "shill/mock_wimax_service.h"
#include "shill/nice_mock_control.h"
-#include "shill/proxy_factory.h"
+#include "shill/testing.h"
using base::Bind;
using base::Unretained;
@@ -43,7 +40,6 @@
public:
WiMaxTest()
: proxy_(new MockWiMaxDeviceProxy()),
- proxy_factory_(this),
metrics_(&dispatcher_),
manager_(&control_, &dispatcher_, &metrics_, NULL),
dhcp_config_(new MockDHCPConfig(&control_,
@@ -55,21 +51,6 @@
virtual ~WiMaxTest() {}
protected:
- class TestProxyFactory : public ProxyFactory {
- public:
- explicit TestProxyFactory(WiMaxTest *test) : test_(test) {}
-
- virtual WiMaxDeviceProxyInterface *CreateWiMaxDeviceProxy(
- const string &/*path*/) {
- return test_->proxy_.release();
- }
-
- private:
- WiMaxTest *test_;
-
- DISALLOW_COPY_AND_ASSIGN(TestProxyFactory);
- };
-
class Target {
public:
virtual ~Target() {}
@@ -89,7 +70,7 @@
}
scoped_ptr<MockWiMaxDeviceProxy> proxy_;
- TestProxyFactory proxy_factory_;
+ MockProxyFactory proxy_factory_;
NiceMockControl control_;
EventDispatcher dispatcher_;
NiceMock<MockMetrics> metrics_;
@@ -106,6 +87,8 @@
TEST_F(WiMaxTest, StartStop) {
EXPECT_FALSE(device_->proxy_.get());
+ EXPECT_CALL(proxy_factory_, CreateWiMaxDeviceProxy(_))
+ .WillOnce(ReturnAndReleasePointee(&proxy_));
EXPECT_CALL(*proxy_, Enable(_, _, _));
EXPECT_CALL(*proxy_, set_networks_changed_callback(_));
EXPECT_CALL(*proxy_, set_status_changed_callback(_));