| Index: third_party/WebKit/Source/core/page/NetworkStateNotifierTest.cpp
|
| diff --git a/third_party/WebKit/Source/core/page/NetworkStateNotifierTest.cpp b/third_party/WebKit/Source/core/page/NetworkStateNotifierTest.cpp
|
| index 5d189315bfa22feffefca09df1fa178b13c64388..3a33be33b2f2f4c6d268fcb4c5309f76b427d8a7 100644
|
| --- a/third_party/WebKit/Source/core/page/NetworkStateNotifierTest.cpp
|
| +++ b/third_party/WebKit/Source/core/page/NetworkStateNotifierTest.cpp
|
| @@ -278,4 +278,68 @@ TEST_F(NetworkStateNotifierTest, RemoveAllContexts)
|
| EXPECT_TRUE(verifyObservations(observer2, WebConnectionTypeNone, kNoneMaxBandwidthMbps));
|
| }
|
|
|
| +TEST_F(NetworkStateNotifierTest, SetOverride)
|
| +{
|
| + StateObserver observer;
|
| + m_notifier.addObserver(&observer, getExecutionContext());
|
| +
|
| + m_notifier.setOnLine(true);
|
| + setConnection(WebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps);
|
| + EXPECT_TRUE(verifyObservations(observer, WebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps));
|
| + EXPECT_TRUE(m_notifier.onLine());
|
| + EXPECT_EQ(WebConnectionTypeBluetooth, m_notifier.connectionType());
|
| + EXPECT_EQ(kBluetoothMaxBandwidthMbps, m_notifier.maxBandwidth());
|
| +
|
| + m_notifier.setOverride(true, WebConnectionTypeEthernet, kEthernetMaxBandwidthMbps);
|
| + testing::runPendingTasks();
|
| + EXPECT_TRUE(verifyObservations(observer, WebConnectionTypeEthernet, kEthernetMaxBandwidthMbps));
|
| + EXPECT_TRUE(m_notifier.onLine());
|
| + EXPECT_EQ(WebConnectionTypeEthernet, m_notifier.connectionType());
|
| + EXPECT_EQ(kEthernetMaxBandwidthMbps, m_notifier.maxBandwidth());
|
| +
|
| + // When override is active, calls to setOnLine and setConnection are temporary ignored.
|
| + m_notifier.setOnLine(false);
|
| + setConnection(WebConnectionTypeNone, kNoneMaxBandwidthMbps);
|
| + testing::runPendingTasks();
|
| + EXPECT_TRUE(verifyObservations(observer, WebConnectionTypeEthernet, kEthernetMaxBandwidthMbps));
|
| + EXPECT_TRUE(m_notifier.onLine());
|
| + EXPECT_EQ(WebConnectionTypeEthernet, m_notifier.connectionType());
|
| + EXPECT_EQ(kEthernetMaxBandwidthMbps, m_notifier.maxBandwidth());
|
| +
|
| + m_notifier.clearOverride();
|
| + testing::runPendingTasks();
|
| + EXPECT_TRUE(verifyObservations(observer, WebConnectionTypeNone, kNoneMaxBandwidthMbps));
|
| + EXPECT_FALSE(m_notifier.onLine());
|
| + EXPECT_EQ(WebConnectionTypeNone, m_notifier.connectionType());
|
| + EXPECT_EQ(kNoneMaxBandwidthMbps, m_notifier.maxBandwidth());
|
| +
|
| + m_notifier.removeObserver(&observer, getExecutionContext());
|
| +}
|
| +
|
| +TEST_F(NetworkStateNotifierTest, NoExtraNotifications)
|
| +{
|
| + StateObserver observer;
|
| + m_notifier.addObserver(&observer, getExecutionContext());
|
| +
|
| + setConnection(WebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps);
|
| + EXPECT_TRUE(verifyObservations(observer, WebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps));
|
| + EXPECT_EQ(observer.callbackCount(), 1);
|
| +
|
| + setConnection(WebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps);
|
| + EXPECT_EQ(observer.callbackCount(), 1);
|
| +
|
| + setConnection(WebConnectionTypeEthernet, kEthernetMaxBandwidthMbps);
|
| + EXPECT_TRUE(verifyObservations(observer, WebConnectionTypeEthernet, kEthernetMaxBandwidthMbps));
|
| + EXPECT_EQ(observer.callbackCount(), 2);
|
| +
|
| + setConnection(WebConnectionTypeEthernet, kEthernetMaxBandwidthMbps);
|
| + EXPECT_EQ(observer.callbackCount(), 2);
|
| +
|
| + setConnection(WebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps);
|
| + EXPECT_TRUE(verifyObservations(observer, WebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps));
|
| + EXPECT_EQ(observer.callbackCount(), 3);
|
| +
|
| + m_notifier.removeObserver(&observer, getExecutionContext());
|
| +}
|
| +
|
| } // namespace blink
|
|
|