Chromium Code Reviews| Index: third_party/WebKit/Source/platform/network/NetworkStateNotifierTest.cpp |
| diff --git a/third_party/WebKit/Source/platform/network/NetworkStateNotifierTest.cpp b/third_party/WebKit/Source/platform/network/NetworkStateNotifierTest.cpp |
| index 3600f0568aefd8fd9beb046366f57b8c8910e4ab..7748f10a3cf32574ed2853160b2cfdd6b80e31d5 100644 |
| --- a/third_party/WebKit/Source/platform/network/NetworkStateNotifierTest.cpp |
| +++ b/third_party/WebKit/Source/platform/network/NetworkStateNotifierTest.cpp |
| @@ -46,6 +46,11 @@ namespace { |
| const double kNoneMaxBandwidthMbps = 0.0; |
| const double kBluetoothMaxBandwidthMbps = 1.0; |
| const double kEthernetMaxBandwidthMbps = 2.0; |
| +const int kEthernetHttpRtt = 50; |
| +const int kEthernetTransportRtt = 25; |
| +const double kEthernetThroughputMbps = 75.0; |
| +const int kUnknownRtt = -1; |
| +const double kUnknownThroughputMbps = -1.0; |
| } |
| class StateObserver : public NetworkStateNotifier::NetworkStateObserver { |
| @@ -53,13 +58,22 @@ class StateObserver : public NetworkStateNotifier::NetworkStateObserver { |
| StateObserver() |
| : observed_type_(kWebConnectionTypeNone), |
| observed_max_bandwidth_mbps_(0.0), |
| + observed_http_rtt_msec_(kUnknownRtt), |
| + observed_transport_rtt_msec_(kUnknownRtt), |
| + observed_downlink_throughput_mbps_(kUnknownThroughputMbps), |
| observed_on_line_state_(false), |
| callback_count_(0) {} |
| virtual void ConnectionChange(WebConnectionType type, |
| - double max_bandwidth_mbps) { |
| + double max_bandwidth_mbps, |
| + int http_rtt_msec, |
| + int transport_rtt_msec, |
| + double downlink_throughput_mbps) { |
| observed_type_ = type; |
| observed_max_bandwidth_mbps_ = max_bandwidth_mbps; |
| + observed_http_rtt_msec_ = http_rtt_msec; |
| + observed_transport_rtt_msec_ = transport_rtt_msec; |
| + observed_downlink_throughput_mbps_ = downlink_throughput_mbps; |
| callback_count_ += 1; |
| if (closure_) |
| @@ -76,6 +90,13 @@ class StateObserver : public NetworkStateNotifier::NetworkStateObserver { |
| WebConnectionType ObservedType() const { return observed_type_; } |
| double ObservedMaxBandwidth() const { return observed_max_bandwidth_mbps_; } |
| + double ObservedHttpRttMsec() const { return observed_http_rtt_msec_; } |
| + double ObservedTransportRttMsec() const { |
| + return observed_transport_rtt_msec_; |
| + } |
| + double ObservedDownlinkThroughputMbps() const { |
| + return observed_downlink_throughput_mbps_; |
| + } |
| bool ObservedOnLineState() const { return observed_on_line_state_; } |
| int CallbackCount() const { return callback_count_; } |
| @@ -87,6 +108,9 @@ class StateObserver : public NetworkStateNotifier::NetworkStateObserver { |
| std::unique_ptr<WTF::Closure> closure_; |
| WebConnectionType observed_type_; |
| double observed_max_bandwidth_mbps_; |
| + int observed_http_rtt_msec_; |
| + int observed_transport_rtt_msec_; |
| + double observed_downlink_throughput_mbps_; |
| bool observed_on_line_state_; |
| int callback_count_; |
| }; |
| @@ -117,8 +141,14 @@ class NetworkStateNotifierTest : public ::testing::Test { |
| task_runner2_->RunUntilIdle(); |
| } |
| - void SetConnection(WebConnectionType type, double max_bandwidth_mbps) { |
| + void SetConnection(WebConnectionType type, |
| + double max_bandwidth_mbps, |
| + int http_rtt_msec, |
| + int transport_rtt_msec, |
| + int downlink_throughput_mbps) { |
| notifier_.SetWebConnection(type, max_bandwidth_mbps); |
| + notifier_.SetWebNetworkQuality(http_rtt_msec, transport_rtt_msec, |
| + downlink_throughput_mbps * 1000); |
| RunPendingTasks(); |
| } |
| void SetOnLine(bool on_line) { |
| @@ -144,11 +174,23 @@ class NetworkStateNotifierTest : public ::testing::Test { |
| bool VerifyObservations(const StateObserver& observer, |
| WebConnectionType type, |
| - double max_bandwidth_mbps) { |
| - EXPECT_EQ(observer.ObservedType(), type); |
| - EXPECT_EQ(observer.ObservedMaxBandwidth(), max_bandwidth_mbps); |
| + double max_bandwidth_mbps, |
| + double http_rtt_msec, |
| + double transport_rtt_msec, |
| + double downlink_throughput_mbps) const { |
| + EXPECT_EQ(type, observer.ObservedType()); |
| + EXPECT_EQ(max_bandwidth_mbps, observer.ObservedMaxBandwidth()); |
| + EXPECT_EQ(http_rtt_msec, observer.ObservedHttpRttMsec()); |
| + EXPECT_EQ(transport_rtt_msec, observer.ObservedTransportRttMsec()); |
| + EXPECT_EQ(downlink_throughput_mbps, |
| + observer.ObservedDownlinkThroughputMbps()); |
| + |
| return observer.ObservedType() == type && |
| - observer.ObservedMaxBandwidth() == max_bandwidth_mbps; |
| + observer.ObservedMaxBandwidth() == max_bandwidth_mbps && |
| + observer.ObservedHttpRttMsec() == http_rtt_msec && |
| + observer.ObservedTransportRttMsec() == transport_rtt_msec && |
| + observer.ObservedDownlinkThroughputMbps() == |
| + downlink_throughput_mbps; |
| } |
| RefPtr<FakeWebTaskRunner> task_runner_; |
| @@ -160,12 +202,16 @@ TEST_F(NetworkStateNotifierTest, AddObserver) { |
| StateObserver observer; |
| notifier_.AddConnectionObserver(&observer, GetTaskRunner()); |
| EXPECT_TRUE(VerifyObservations(observer, kWebConnectionTypeNone, |
| - kNoneMaxBandwidthMbps)); |
| + kNoneMaxBandwidthMbps, kUnknownRtt, |
| + kUnknownRtt, kUnknownThroughputMbps)); |
| + SetConnection(kWebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps, |
| + kEthernetHttpRtt, kEthernetTransportRtt, |
| + kEthernetThroughputMbps); |
| + EXPECT_TRUE(VerifyObservations( |
| + observer, kWebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps, |
| + kEthernetHttpRtt, kEthernetTransportRtt, kEthernetThroughputMbps)); |
| + EXPECT_EQ(observer.CallbackCount(), 2); |
|
jkarlin
2017/05/16 14:32:59
Can you verify that changing just the connection t
tbansal1
2017/05/16 18:23:28
Done.
|
| - SetConnection(kWebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps); |
| - EXPECT_TRUE(VerifyObservations(observer, kWebConnectionTypeBluetooth, |
| - kBluetoothMaxBandwidthMbps)); |
| - EXPECT_EQ(observer.CallbackCount(), 1); |
| notifier_.RemoveConnectionObserver(&observer, GetTaskRunner()); |
| } |
| @@ -175,11 +221,16 @@ TEST_F(NetworkStateNotifierTest, RemoveObserver) { |
| notifier_.RemoveConnectionObserver(&observer1, GetTaskRunner()); |
| notifier_.AddConnectionObserver(&observer2, GetTaskRunner()); |
| - SetConnection(kWebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps); |
| + SetConnection(kWebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps, |
| + kEthernetHttpRtt, kEthernetTransportRtt, |
| + kEthernetThroughputMbps); |
| + |
| EXPECT_TRUE(VerifyObservations(observer1, kWebConnectionTypeNone, |
| - kNoneMaxBandwidthMbps)); |
| - EXPECT_TRUE(VerifyObservations(observer2, kWebConnectionTypeBluetooth, |
| - kBluetoothMaxBandwidthMbps)); |
| + kNoneMaxBandwidthMbps, kUnknownRtt, |
| + kUnknownRtt, kUnknownThroughputMbps)); |
| + EXPECT_TRUE(VerifyObservations( |
| + observer2, kWebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps, |
| + kEthernetHttpRtt, kEthernetTransportRtt, kEthernetThroughputMbps)); |
| notifier_.RemoveConnectionObserver(&observer2, GetTaskRunner()); |
| } |
| @@ -188,9 +239,12 @@ TEST_F(NetworkStateNotifierTest, RemoveSoleObserver) { |
| notifier_.AddConnectionObserver(&observer1, GetTaskRunner()); |
| notifier_.RemoveConnectionObserver(&observer1, GetTaskRunner()); |
| - SetConnection(kWebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps); |
| + SetConnection(kWebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps, |
| + kEthernetHttpRtt, kEthernetTransportRtt, |
| + kEthernetThroughputMbps); |
| EXPECT_TRUE(VerifyObservations(observer1, kWebConnectionTypeNone, |
| - kNoneMaxBandwidthMbps)); |
| + kNoneMaxBandwidthMbps, kUnknownRtt, |
| + kUnknownRtt, kUnknownThroughputMbps)); |
| } |
| TEST_F(NetworkStateNotifierTest, AddObserverWhileNotifying) { |
| @@ -198,11 +252,14 @@ TEST_F(NetworkStateNotifierTest, AddObserverWhileNotifying) { |
| notifier_.AddConnectionObserver(&observer1, GetTaskRunner()); |
| AddObserverOnNotification(&observer1, &observer2); |
| - SetConnection(kWebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps); |
| + SetConnection(kWebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps, |
| + kUnknownRtt, kUnknownRtt, kUnknownThroughputMbps); |
| EXPECT_TRUE(VerifyObservations(observer1, kWebConnectionTypeBluetooth, |
| - kBluetoothMaxBandwidthMbps)); |
| + kBluetoothMaxBandwidthMbps, kUnknownRtt, |
| + kUnknownRtt, kUnknownThroughputMbps)); |
| EXPECT_TRUE(VerifyObservations(observer2, kWebConnectionTypeBluetooth, |
| - kBluetoothMaxBandwidthMbps)); |
| + kBluetoothMaxBandwidthMbps, kUnknownRtt, |
| + kUnknownRtt, kUnknownThroughputMbps)); |
| notifier_.RemoveConnectionObserver(&observer1, GetTaskRunner()); |
| notifier_.RemoveConnectionObserver(&observer2, GetTaskRunner()); |
| } |
| @@ -212,13 +269,17 @@ TEST_F(NetworkStateNotifierTest, RemoveSoleObserverWhileNotifying) { |
| notifier_.AddConnectionObserver(&observer1, GetTaskRunner()); |
| RemoveObserverOnNotification(&observer1, &observer1); |
| - SetConnection(kWebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps); |
| + SetConnection(kWebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps, |
| + kUnknownRtt, kUnknownRtt, kUnknownThroughputMbps); |
| EXPECT_TRUE(VerifyObservations(observer1, kWebConnectionTypeBluetooth, |
| - kBluetoothMaxBandwidthMbps)); |
| + kBluetoothMaxBandwidthMbps, kUnknownRtt, |
| + kUnknownRtt, kUnknownRtt)); |
| - SetConnection(kWebConnectionTypeEthernet, kEthernetMaxBandwidthMbps); |
| + SetConnection(kWebConnectionTypeEthernet, kEthernetMaxBandwidthMbps, |
| + kUnknownRtt, kUnknownRtt, kUnknownThroughputMbps); |
| EXPECT_TRUE(VerifyObservations(observer1, kWebConnectionTypeBluetooth, |
| - kBluetoothMaxBandwidthMbps)); |
| + kBluetoothMaxBandwidthMbps, kUnknownRtt, |
| + kUnknownRtt, kUnknownThroughputMbps)); |
| } |
| TEST_F(NetworkStateNotifierTest, RemoveCurrentObserverWhileNotifying) { |
| @@ -227,17 +288,23 @@ TEST_F(NetworkStateNotifierTest, RemoveCurrentObserverWhileNotifying) { |
| notifier_.AddConnectionObserver(&observer2, GetTaskRunner()); |
| RemoveObserverOnNotification(&observer1, &observer1); |
| - SetConnection(kWebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps); |
| + SetConnection(kWebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps, |
| + kUnknownRtt, kUnknownRtt, kUnknownThroughputMbps); |
| EXPECT_TRUE(VerifyObservations(observer1, kWebConnectionTypeBluetooth, |
| - kBluetoothMaxBandwidthMbps)); |
| + kBluetoothMaxBandwidthMbps, kUnknownRtt, |
| + kUnknownRtt, kUnknownThroughputMbps)); |
| EXPECT_TRUE(VerifyObservations(observer2, kWebConnectionTypeBluetooth, |
| - kBluetoothMaxBandwidthMbps)); |
| + kBluetoothMaxBandwidthMbps, kUnknownRtt, |
| + kUnknownRtt, kUnknownThroughputMbps)); |
| - SetConnection(kWebConnectionTypeEthernet, kEthernetMaxBandwidthMbps); |
| + SetConnection(kWebConnectionTypeEthernet, kEthernetMaxBandwidthMbps, |
| + kUnknownRtt, kUnknownRtt, kUnknownThroughputMbps); |
| EXPECT_TRUE(VerifyObservations(observer1, kWebConnectionTypeBluetooth, |
| - kBluetoothMaxBandwidthMbps)); |
| + kBluetoothMaxBandwidthMbps, kUnknownRtt, |
| + kUnknownRtt, kUnknownThroughputMbps)); |
| EXPECT_TRUE(VerifyObservations(observer2, kWebConnectionTypeEthernet, |
| - kEthernetMaxBandwidthMbps)); |
| + kEthernetMaxBandwidthMbps, kUnknownRtt, |
| + kUnknownRtt, kUnknownThroughputMbps)); |
| notifier_.RemoveConnectionObserver(&observer1, GetTaskRunner()); |
| notifier_.RemoveConnectionObserver(&observer2, GetTaskRunner()); |
| @@ -249,15 +316,19 @@ TEST_F(NetworkStateNotifierTest, RemovePastObserverWhileNotifying) { |
| notifier_.AddConnectionObserver(&observer2, GetTaskRunner()); |
| RemoveObserverOnNotification(&observer2, &observer1); |
| - SetConnection(kWebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps); |
| + SetConnection(kWebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps, |
| + kUnknownRtt, kUnknownRtt, kUnknownThroughputMbps); |
| EXPECT_EQ(observer1.ObservedType(), kWebConnectionTypeBluetooth); |
| EXPECT_EQ(observer2.ObservedType(), kWebConnectionTypeBluetooth); |
| - SetConnection(kWebConnectionTypeEthernet, kEthernetMaxBandwidthMbps); |
| + SetConnection(kWebConnectionTypeEthernet, kEthernetMaxBandwidthMbps, |
| + kUnknownRtt, kUnknownRtt, kUnknownThroughputMbps); |
| EXPECT_TRUE(VerifyObservations(observer1, kWebConnectionTypeBluetooth, |
| - kBluetoothMaxBandwidthMbps)); |
| + kBluetoothMaxBandwidthMbps, kUnknownRtt, |
| + kUnknownRtt, kUnknownThroughputMbps)); |
| EXPECT_TRUE(VerifyObservations(observer2, kWebConnectionTypeEthernet, |
| - kEthernetMaxBandwidthMbps)); |
| + kEthernetMaxBandwidthMbps, kUnknownRtt, |
| + kUnknownRtt, kUnknownThroughputMbps)); |
| notifier_.RemoveConnectionObserver(&observer1, GetTaskRunner()); |
| notifier_.RemoveConnectionObserver(&observer2, GetTaskRunner()); |
| @@ -270,13 +341,17 @@ TEST_F(NetworkStateNotifierTest, RemoveFutureObserverWhileNotifying) { |
| notifier_.AddConnectionObserver(&observer3, GetTaskRunner()); |
| RemoveObserverOnNotification(&observer1, &observer2); |
| - SetConnection(kWebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps); |
| + SetConnection(kWebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps, |
| + kUnknownRtt, kUnknownRtt, kUnknownThroughputMbps); |
| EXPECT_TRUE(VerifyObservations(observer1, kWebConnectionTypeBluetooth, |
| - kBluetoothMaxBandwidthMbps)); |
| + kBluetoothMaxBandwidthMbps, kUnknownRtt, |
| + kUnknownRtt, kUnknownThroughputMbps)); |
| EXPECT_TRUE(VerifyObservations(observer2, kWebConnectionTypeNone, |
| - kNoneMaxBandwidthMbps)); |
| + kNoneMaxBandwidthMbps, kUnknownRtt, |
| + kUnknownRtt, kUnknownThroughputMbps)); |
| EXPECT_TRUE(VerifyObservations(observer3, kWebConnectionTypeBluetooth, |
| - kBluetoothMaxBandwidthMbps)); |
| + kBluetoothMaxBandwidthMbps, kUnknownRtt, |
| + kUnknownRtt, kUnknownThroughputMbps)); |
| notifier_.RemoveConnectionObserver(&observer1, GetTaskRunner()); |
| notifier_.RemoveConnectionObserver(&observer2, GetTaskRunner()); |
| @@ -288,11 +363,15 @@ TEST_F(NetworkStateNotifierTest, MultipleContextsAddObserver) { |
| notifier_.AddConnectionObserver(&observer1, GetTaskRunner()); |
| notifier_.AddConnectionObserver(&observer2, GetTaskRunner2()); |
| - SetConnection(kWebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps); |
| - EXPECT_TRUE(VerifyObservations(observer1, kWebConnectionTypeBluetooth, |
| - kBluetoothMaxBandwidthMbps)); |
| - EXPECT_TRUE(VerifyObservations(observer2, kWebConnectionTypeBluetooth, |
| - kBluetoothMaxBandwidthMbps)); |
| + SetConnection(kWebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps, |
| + kEthernetHttpRtt, kEthernetTransportRtt, |
| + kEthernetThroughputMbps); |
| + EXPECT_TRUE(VerifyObservations( |
| + observer1, kWebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps, |
| + kEthernetHttpRtt, kEthernetTransportRtt, kEthernetThroughputMbps)); |
| + EXPECT_TRUE(VerifyObservations( |
| + observer2, kWebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps, |
| + kEthernetHttpRtt, kEthernetTransportRtt, kEthernetThroughputMbps)); |
| notifier_.RemoveConnectionObserver(&observer1, GetTaskRunner()); |
| notifier_.RemoveConnectionObserver(&observer2, GetTaskRunner2()); |
| @@ -304,11 +383,15 @@ TEST_F(NetworkStateNotifierTest, RemoveContext) { |
| notifier_.AddConnectionObserver(&observer2, GetTaskRunner2()); |
| notifier_.RemoveConnectionObserver(&observer2, GetTaskRunner2()); |
| - SetConnection(kWebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps); |
| - EXPECT_TRUE(VerifyObservations(observer1, kWebConnectionTypeBluetooth, |
| - kBluetoothMaxBandwidthMbps)); |
| + SetConnection(kWebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps, |
| + kEthernetHttpRtt, kEthernetTransportRtt, |
| + kEthernetThroughputMbps); |
| + EXPECT_TRUE(VerifyObservations( |
| + observer1, kWebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps, |
| + kEthernetHttpRtt, kEthernetTransportRtt, kEthernetThroughputMbps)); |
| EXPECT_TRUE(VerifyObservations(observer2, kWebConnectionTypeNone, |
| - kNoneMaxBandwidthMbps)); |
| + kNoneMaxBandwidthMbps, kUnknownRtt, |
| + kUnknownRtt, kUnknownThroughputMbps)); |
| notifier_.RemoveConnectionObserver(&observer1, GetTaskRunner()); |
| } |
| @@ -320,11 +403,15 @@ TEST_F(NetworkStateNotifierTest, RemoveAllContexts) { |
| notifier_.RemoveConnectionObserver(&observer1, GetTaskRunner()); |
| notifier_.RemoveConnectionObserver(&observer2, GetTaskRunner2()); |
| - SetConnection(kWebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps); |
| + SetConnection(kWebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps, |
| + kEthernetHttpRtt, kEthernetTransportRtt, |
| + kEthernetThroughputMbps); |
| EXPECT_TRUE(VerifyObservations(observer1, kWebConnectionTypeNone, |
| - kNoneMaxBandwidthMbps)); |
| + kNoneMaxBandwidthMbps, kUnknownRtt, |
| + kUnknownRtt, kUnknownThroughputMbps)); |
| EXPECT_TRUE(VerifyObservations(observer2, kWebConnectionTypeNone, |
| - kNoneMaxBandwidthMbps)); |
| + kNoneMaxBandwidthMbps, kUnknownRtt, |
| + kUnknownRtt, kUnknownThroughputMbps)); |
| } |
| TEST_F(NetworkStateNotifierTest, SetOverride) { |
| @@ -332,9 +419,11 @@ TEST_F(NetworkStateNotifierTest, SetOverride) { |
| notifier_.AddConnectionObserver(&observer, GetTaskRunner()); |
| notifier_.SetOnLine(true); |
| - SetConnection(kWebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps); |
| + SetConnection(kWebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps, |
| + kUnknownRtt, kUnknownRtt, kUnknownThroughputMbps); |
| EXPECT_TRUE(VerifyObservations(observer, kWebConnectionTypeBluetooth, |
| - kBluetoothMaxBandwidthMbps)); |
| + kBluetoothMaxBandwidthMbps, kUnknownRtt, |
| + kUnknownRtt, kUnknownThroughputMbps)); |
| EXPECT_TRUE(notifier_.OnLine()); |
| EXPECT_EQ(kWebConnectionTypeBluetooth, notifier_.ConnectionType()); |
| EXPECT_EQ(kBluetoothMaxBandwidthMbps, notifier_.MaxBandwidth()); |
| @@ -343,7 +432,8 @@ TEST_F(NetworkStateNotifierTest, SetOverride) { |
| kEthernetMaxBandwidthMbps); |
| RunPendingTasks(); |
| EXPECT_TRUE(VerifyObservations(observer, kWebConnectionTypeEthernet, |
| - kEthernetMaxBandwidthMbps)); |
| + kEthernetMaxBandwidthMbps, kUnknownRtt, |
| + kUnknownRtt, kUnknownThroughputMbps)); |
| EXPECT_TRUE(notifier_.OnLine()); |
| EXPECT_EQ(kWebConnectionTypeEthernet, notifier_.ConnectionType()); |
| EXPECT_EQ(kEthernetMaxBandwidthMbps, notifier_.MaxBandwidth()); |
| @@ -351,10 +441,12 @@ TEST_F(NetworkStateNotifierTest, SetOverride) { |
| // When override is active, calls to setOnLine and setConnection are temporary |
| // ignored. |
| notifier_.SetOnLine(false); |
| - SetConnection(kWebConnectionTypeNone, kNoneMaxBandwidthMbps); |
| + SetConnection(kWebConnectionTypeNone, kNoneMaxBandwidthMbps, kUnknownRtt, |
| + kUnknownRtt, kUnknownThroughputMbps); |
| RunPendingTasks(); |
| EXPECT_TRUE(VerifyObservations(observer, kWebConnectionTypeEthernet, |
| - kEthernetMaxBandwidthMbps)); |
| + kEthernetMaxBandwidthMbps, kUnknownRtt, |
| + kUnknownRtt, kUnknownThroughputMbps)); |
| EXPECT_TRUE(notifier_.OnLine()); |
| EXPECT_EQ(kWebConnectionTypeEthernet, notifier_.ConnectionType()); |
| EXPECT_EQ(kEthernetMaxBandwidthMbps, notifier_.MaxBandwidth()); |
| @@ -362,7 +454,8 @@ TEST_F(NetworkStateNotifierTest, SetOverride) { |
| notifier_.ClearOverride(); |
| RunPendingTasks(); |
| EXPECT_TRUE(VerifyObservations(observer, kWebConnectionTypeNone, |
| - kNoneMaxBandwidthMbps)); |
| + kNoneMaxBandwidthMbps, kUnknownRtt, |
| + kUnknownRtt, kUnknownThroughputMbps)); |
| EXPECT_FALSE(notifier_.OnLine()); |
| EXPECT_EQ(kWebConnectionTypeNone, notifier_.ConnectionType()); |
| EXPECT_EQ(kNoneMaxBandwidthMbps, notifier_.MaxBandwidth()); |
| @@ -374,26 +467,40 @@ TEST_F(NetworkStateNotifierTest, NoExtraNotifications) { |
| StateObserver observer; |
| notifier_.AddConnectionObserver(&observer, GetTaskRunner()); |
| - SetConnection(kWebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps); |
| - EXPECT_TRUE(VerifyObservations(observer, kWebConnectionTypeBluetooth, |
| - kBluetoothMaxBandwidthMbps)); |
| - EXPECT_EQ(observer.CallbackCount(), 1); |
| - |
| - SetConnection(kWebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps); |
| - EXPECT_EQ(observer.CallbackCount(), 1); |
| - |
| - SetConnection(kWebConnectionTypeEthernet, kEthernetMaxBandwidthMbps); |
| - EXPECT_TRUE(VerifyObservations(observer, kWebConnectionTypeEthernet, |
| - kEthernetMaxBandwidthMbps)); |
| + SetConnection(kWebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps, |
| + kEthernetHttpRtt, kEthernetTransportRtt, |
| + kEthernetThroughputMbps); |
| + EXPECT_TRUE(VerifyObservations( |
| + observer, kWebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps, |
| + kEthernetHttpRtt, kEthernetTransportRtt, kEthernetThroughputMbps)); |
| EXPECT_EQ(observer.CallbackCount(), 2); |
| - SetConnection(kWebConnectionTypeEthernet, kEthernetMaxBandwidthMbps); |
| + SetConnection(kWebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps, |
| + kEthernetHttpRtt, kEthernetTransportRtt, |
| + kEthernetThroughputMbps); |
| EXPECT_EQ(observer.CallbackCount(), 2); |
| - SetConnection(kWebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps); |
| - EXPECT_TRUE(VerifyObservations(observer, kWebConnectionTypeBluetooth, |
| - kBluetoothMaxBandwidthMbps)); |
| - EXPECT_EQ(observer.CallbackCount(), 3); |
| + SetConnection(kWebConnectionTypeEthernet, kEthernetMaxBandwidthMbps, |
| + kEthernetHttpRtt * 2, kEthernetTransportRtt * 2, |
| + kEthernetThroughputMbps * 2); |
| + EXPECT_TRUE(VerifyObservations( |
| + observer, kWebConnectionTypeEthernet, kEthernetMaxBandwidthMbps, |
| + kEthernetHttpRtt * 2, kEthernetTransportRtt * 2, |
| + kEthernetThroughputMbps * 2)); |
| + EXPECT_EQ(observer.CallbackCount(), 4); |
| + |
| + SetConnection(kWebConnectionTypeEthernet, kEthernetMaxBandwidthMbps, |
| + kEthernetHttpRtt * 2, kEthernetTransportRtt * 2, |
| + kEthernetThroughputMbps * 2); |
| + EXPECT_EQ(observer.CallbackCount(), 4); |
| + |
| + SetConnection(kWebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps, |
| + kEthernetHttpRtt, kEthernetTransportRtt, |
| + kEthernetThroughputMbps); |
| + EXPECT_TRUE(VerifyObservations( |
| + observer, kWebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps, |
| + kEthernetHttpRtt, kEthernetTransportRtt, kEthernetThroughputMbps)); |
| + EXPECT_EQ(observer.CallbackCount(), 6); |
| notifier_.RemoveConnectionObserver(&observer, GetTaskRunner()); |
| } |
| @@ -476,15 +583,17 @@ TEST_F(NetworkStateNotifierTest, MultipleObservers) { |
| EXPECT_EQ(observer2.CallbackCount(), 2); |
| notifier_.SetOnLine(true); |
| - notifier_.SetWebConnection(kWebConnectionTypeEthernet, |
| - kEthernetMaxBandwidthMbps); |
| - RunPendingTasks(); |
| + SetConnection(kWebConnectionTypeEthernet, kEthernetMaxBandwidthMbps, |
| + kEthernetHttpRtt, kEthernetTransportRtt, |
| + kEthernetThroughputMbps); |
| + |
| EXPECT_TRUE(observer1.ObservedOnLineState()); |
| EXPECT_TRUE(observer2.ObservedOnLineState()); |
| - EXPECT_TRUE(VerifyObservations(observer2, kWebConnectionTypeEthernet, |
| - kEthernetMaxBandwidthMbps)); |
| + EXPECT_TRUE(VerifyObservations( |
| + observer2, kWebConnectionTypeEthernet, kEthernetMaxBandwidthMbps, |
| + kEthernetHttpRtt, kEthernetTransportRtt, kEthernetThroughputMbps)); |
| EXPECT_EQ(observer1.CallbackCount(), 3); |
| - EXPECT_EQ(observer2.CallbackCount(), 4); |
| + EXPECT_EQ(observer2.CallbackCount(), 5); |
| notifier_.RemoveConnectionObserver(&observer1, GetTaskRunner()); |
| notifier_.RemoveConnectionObserver(&observer2, GetTaskRunner()); |