| Index: net/base/network_change_notifier_win_unittest.cc
|
| diff --git a/net/base/network_change_notifier_win_unittest.cc b/net/base/network_change_notifier_win_unittest.cc
|
| index a418ba7ad158c9ceba6757f84a075a168a6dfcba..cb29dd80cdb6bbee50665d726598fb8eb2e45fc4 100644
|
| --- a/net/base/network_change_notifier_win_unittest.cc
|
| +++ b/net/base/network_change_notifier_win_unittest.cc
|
| @@ -11,8 +11,10 @@
|
|
|
| using ::testing::AtLeast;
|
| using ::testing::Invoke;
|
| +using ::testing::InvokeWithoutArgs;
|
| using ::testing::Return;
|
| using ::testing::StrictMock;
|
| +using ::testing::_;
|
|
|
| namespace net {
|
|
|
| @@ -43,21 +45,21 @@ class TestNetworkChangeNotifierWin : public NetworkChangeNotifierWin {
|
| DISALLOW_COPY_AND_ASSIGN(TestNetworkChangeNotifierWin);
|
| };
|
|
|
| -class TestIPAddressObserver
|
| - : public net::NetworkChangeNotifier::IPAddressObserver {
|
| +class TestNetworkChangeObserver
|
| + : public net::NetworkChangeNotifier::NetworkChangeObserver {
|
| public:
|
| - TestIPAddressObserver() {
|
| - NetworkChangeNotifier::AddIPAddressObserver(this);
|
| + TestNetworkChangeObserver() {
|
| + NetworkChangeNotifier::AddNetworkChangeObserver(this);
|
| }
|
|
|
| - ~TestIPAddressObserver() {
|
| - NetworkChangeNotifier::RemoveIPAddressObserver(this);
|
| + ~TestNetworkChangeObserver() {
|
| + NetworkChangeNotifier::RemoveNetworkChangeObserver(this);
|
| }
|
|
|
| - MOCK_METHOD0(OnIPAddressChanged, void());
|
| + MOCK_METHOD1(OnNetworkChanged, void(NetworkChangeNotifier::ConnectionType));
|
|
|
| private:
|
| - DISALLOW_COPY_AND_ASSIGN(TestIPAddressObserver);
|
| + DISALLOW_COPY_AND_ASSIGN(TestNetworkChangeObserver);
|
| };
|
|
|
| bool ExitMessageLoopAndReturnFalse() {
|
| @@ -69,6 +71,15 @@ bool ExitMessageLoopAndReturnFalse() {
|
|
|
| class NetworkChangeNotifierWinTest : public testing::Test {
|
| public:
|
| + NetworkChangeNotifierWinTest() {
|
| + NetworkChangeNotifier::NetworkChangeCalculatorParams params;
|
| + params.ip_address_offline_delay_ = base::TimeDelta::FromSeconds(0);
|
| + params.ip_address_online_delay_ = base::TimeDelta::FromSeconds(0);
|
| + params.connection_type_offline_delay_ = base::TimeDelta::FromDays(1);
|
| + params.connection_type_online_delay_ = base::TimeDelta::FromDays(1);
|
| + network_change_notifier_.ResetNetworkChangeCalculatorParamsForTest(params);
|
| + }
|
| +
|
| // Calls WatchForAddressChange, and simulates a WatchForAddressChangeInternal
|
| // success. Expects that |network_change_notifier_| has just been created, so
|
| // it's not watching anything yet, and there have been no previous
|
| @@ -77,7 +88,7 @@ class NetworkChangeNotifierWinTest : public testing::Test {
|
| EXPECT_FALSE(network_change_notifier_.is_watching());
|
| EXPECT_EQ(0, network_change_notifier_.sequential_failures());
|
|
|
| - EXPECT_CALL(test_ip_address_observer_, OnIPAddressChanged()).Times(0);
|
| + EXPECT_CALL(test_network_change_observer_, OnNetworkChanged(_)).Times(0);
|
| EXPECT_CALL(network_change_notifier_, WatchForAddressChangeInternal())
|
| .Times(1)
|
| .WillOnce(Return(true));
|
| @@ -98,7 +109,7 @@ class NetworkChangeNotifierWinTest : public testing::Test {
|
| EXPECT_FALSE(network_change_notifier_.is_watching());
|
| EXPECT_EQ(0, network_change_notifier_.sequential_failures());
|
|
|
| - EXPECT_CALL(test_ip_address_observer_, OnIPAddressChanged()).Times(0);
|
| + EXPECT_CALL(test_network_change_observer_, OnNetworkChanged(_)).Times(0);
|
| EXPECT_CALL(network_change_notifier_, WatchForAddressChangeInternal())
|
| // Due to an expected race, it's theoretically possible for more than
|
| // one call to occur, though unlikely.
|
| @@ -121,7 +132,7 @@ class NetworkChangeNotifierWinTest : public testing::Test {
|
| EXPECT_TRUE(network_change_notifier_.is_watching());
|
| EXPECT_EQ(0, network_change_notifier_.sequential_failures());
|
|
|
| - EXPECT_CALL(test_ip_address_observer_, OnIPAddressChanged()).Times(1);
|
| + EXPECT_CALL(test_network_change_observer_, OnNetworkChanged(_)).Times(2);
|
| EXPECT_CALL(network_change_notifier_, WatchForAddressChangeInternal())
|
| .Times(1)
|
| .WillOnce(Return(true));
|
| @@ -141,7 +152,7 @@ class NetworkChangeNotifierWinTest : public testing::Test {
|
| EXPECT_TRUE(network_change_notifier_.is_watching());
|
| EXPECT_EQ(0, network_change_notifier_.sequential_failures());
|
|
|
| - EXPECT_CALL(test_ip_address_observer_, OnIPAddressChanged()).Times(1);
|
| + EXPECT_CALL(test_network_change_observer_, OnNetworkChanged(_)).Times(2);
|
| EXPECT_CALL(network_change_notifier_, WatchForAddressChangeInternal())
|
| // Due to an expected race, it's theoretically possible for more than
|
| // one call to occur, though unlikely.
|
| @@ -165,9 +176,10 @@ class NetworkChangeNotifierWinTest : public testing::Test {
|
| EXPECT_FALSE(network_change_notifier_.is_watching());
|
| EXPECT_LT(0, network_change_notifier_.sequential_failures());
|
|
|
| - EXPECT_CALL(test_ip_address_observer_, OnIPAddressChanged())
|
| - .Times(1)
|
| - .WillOnce(Invoke(MessageLoop::current(), &MessageLoop::Quit));
|
| + EXPECT_CALL(test_network_change_observer_, OnNetworkChanged(_))
|
| + .Times(2)
|
| + .WillRepeatedly(InvokeWithoutArgs(MessageLoop::current(),
|
| + &MessageLoop::Quit));
|
| EXPECT_CALL(network_change_notifier_, WatchForAddressChangeInternal())
|
| .Times(1)
|
| .WillOnce(Return(true));
|
| @@ -189,7 +201,7 @@ class NetworkChangeNotifierWinTest : public testing::Test {
|
| int initial_sequential_failures =
|
| network_change_notifier_.sequential_failures();
|
|
|
| - EXPECT_CALL(test_ip_address_observer_, OnIPAddressChanged()).Times(0);
|
| + EXPECT_CALL(test_network_change_observer_, OnNetworkChanged(_)).Times(0);
|
| EXPECT_CALL(network_change_notifier_, WatchForAddressChangeInternal())
|
| // Due to an expected race, it's theoretically possible for more than
|
| // one call to occur, though unlikely.
|
| @@ -217,8 +229,8 @@ class NetworkChangeNotifierWinTest : public testing::Test {
|
| StrictMock<TestNetworkChangeNotifierWin> network_change_notifier_;
|
|
|
| // Must be created after |network_change_notifier_|, so it can add itself as
|
| - // an IPAddressObserver.
|
| - StrictMock<TestIPAddressObserver> test_ip_address_observer_;
|
| + // a NetworkChangeObserver.
|
| + StrictMock<TestNetworkChangeObserver> test_network_change_observer_;
|
| };
|
|
|
| TEST_F(NetworkChangeNotifierWinTest, NetChangeWinBasic) {
|
|
|