| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014, Google Inc. All rights reserved. | 2 * Copyright (c) 2014, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 EXPECT_TRUE(VerifyObservations( | 578 EXPECT_TRUE(VerifyObservations( |
| 579 observer, kWebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps, | 579 observer, kWebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps, |
| 580 WebEffectiveConnectionType::kTypeUnknown, kUnknownRtt, kUnknownRtt, | 580 WebEffectiveConnectionType::kTypeUnknown, kUnknownRtt, kUnknownRtt, |
| 581 kUnknownThroughputMbps)); | 581 kUnknownThroughputMbps)); |
| 582 EXPECT_TRUE(notifier_.OnLine()); | 582 EXPECT_TRUE(notifier_.OnLine()); |
| 583 EXPECT_EQ(kWebConnectionTypeBluetooth, notifier_.ConnectionType()); | 583 EXPECT_EQ(kWebConnectionTypeBluetooth, notifier_.ConnectionType()); |
| 584 EXPECT_EQ(kBluetoothMaxBandwidthMbps, notifier_.MaxBandwidth()); | 584 EXPECT_EQ(kBluetoothMaxBandwidthMbps, notifier_.MaxBandwidth()); |
| 585 | 585 |
| 586 notifier_.SetNetworkQualityInfoOverride( | 586 notifier_.SetNetworkQualityInfoOverride( |
| 587 WebEffectiveConnectionType::kType3G, | 587 WebEffectiveConnectionType::kType3G, |
| 588 kEthernetTransportRtt.value().InMilliseconds(), | 588 kEthernetHttpRtt.value().InMilliseconds(), |
| 589 kEthernetThroughputMbps.value()); | 589 kEthernetThroughputMbps.value()); |
| 590 RunPendingTasks(); | 590 RunPendingTasks(); |
| 591 EXPECT_TRUE(VerifyObservations( | 591 EXPECT_TRUE(VerifyObservations( |
| 592 observer, kWebConnectionTypeOther, | 592 observer, kWebConnectionTypeOther, |
| 593 NetworkStateNotifier::NetworkState::kInvalidMaxBandwidth, | 593 NetworkStateNotifier::NetworkState::kInvalidMaxBandwidth, |
| 594 WebEffectiveConnectionType::kType3G, kUnknownRtt, kEthernetTransportRtt, | 594 WebEffectiveConnectionType::kType3G, kEthernetHttpRtt, kUnknownRtt, |
| 595 kEthernetThroughputMbps)); | 595 kEthernetThroughputMbps)); |
| 596 EXPECT_TRUE(notifier_.OnLine()); | 596 EXPECT_TRUE(notifier_.OnLine()); |
| 597 EXPECT_EQ(kWebConnectionTypeOther, notifier_.ConnectionType()); | 597 EXPECT_EQ(kWebConnectionTypeOther, notifier_.ConnectionType()); |
| 598 EXPECT_EQ(-1, notifier_.MaxBandwidth()); | 598 EXPECT_EQ(-1, notifier_.MaxBandwidth()); |
| 599 EXPECT_EQ(WebEffectiveConnectionType::kType3G, notifier_.EffectiveType()); | 599 EXPECT_EQ(WebEffectiveConnectionType::kType3G, notifier_.EffectiveType()); |
| 600 EXPECT_EQ(kEthernetTransportRtt, notifier_.TransportRtt()); | 600 EXPECT_EQ(kEthernetHttpRtt, notifier_.HttpRtt()); |
| 601 EXPECT_EQ(kEthernetThroughputMbps, notifier_.DownlinkThroughputMbps()); | 601 EXPECT_EQ(kEthernetThroughputMbps, notifier_.DownlinkThroughputMbps()); |
| 602 | 602 |
| 603 // When override is active, calls to SetConnection are temporary ignored. | 603 // When override is active, calls to SetConnection are temporary ignored. |
| 604 notifier_.SetOnLine(false); | 604 notifier_.SetOnLine(false); |
| 605 SetConnection(kWebConnectionTypeNone, kNoneMaxBandwidthMbps, | 605 SetConnection(kWebConnectionTypeNone, kNoneMaxBandwidthMbps, |
| 606 WebEffectiveConnectionType::kTypeUnknown, kUnknownRtt, | 606 WebEffectiveConnectionType::kTypeUnknown, kUnknownRtt, |
| 607 kUnknownRtt, kUnknownThroughputMbps); | 607 kUnknownRtt, kUnknownThroughputMbps); |
| 608 RunPendingTasks(); | 608 RunPendingTasks(); |
| 609 EXPECT_TRUE(VerifyObservations( | 609 EXPECT_TRUE(VerifyObservations( |
| 610 observer, kWebConnectionTypeOther, | 610 observer, kWebConnectionTypeOther, |
| 611 NetworkStateNotifier::NetworkState::kInvalidMaxBandwidth, | 611 NetworkStateNotifier::NetworkState::kInvalidMaxBandwidth, |
| 612 WebEffectiveConnectionType::kType3G, kUnknownRtt, kEthernetTransportRtt, | 612 WebEffectiveConnectionType::kType3G, kEthernetHttpRtt, kUnknownRtt, |
| 613 kEthernetThroughputMbps)); | 613 kEthernetThroughputMbps)); |
| 614 EXPECT_TRUE(notifier_.OnLine()); | 614 EXPECT_TRUE(notifier_.OnLine()); |
| 615 EXPECT_EQ(kWebConnectionTypeOther, notifier_.ConnectionType()); | 615 EXPECT_EQ(kWebConnectionTypeOther, notifier_.ConnectionType()); |
| 616 EXPECT_EQ(-1, notifier_.MaxBandwidth()); | 616 EXPECT_EQ(-1, notifier_.MaxBandwidth()); |
| 617 EXPECT_EQ(WebEffectiveConnectionType::kType3G, notifier_.EffectiveType()); | 617 EXPECT_EQ(WebEffectiveConnectionType::kType3G, notifier_.EffectiveType()); |
| 618 EXPECT_EQ(kEthernetTransportRtt, notifier_.TransportRtt()); | 618 EXPECT_EQ(kEthernetHttpRtt, notifier_.HttpRtt()); |
| 619 EXPECT_EQ(kEthernetThroughputMbps, notifier_.DownlinkThroughputMbps()); | 619 EXPECT_EQ(kEthernetThroughputMbps, notifier_.DownlinkThroughputMbps()); |
| 620 | 620 |
| 621 // Override the network connection info as well. | 621 // Override the network connection info as well. |
| 622 notifier_.SetNetworkConnectionInfoOverride(true, kWebConnectionTypeEthernet, | 622 notifier_.SetNetworkConnectionInfoOverride(true, kWebConnectionTypeEthernet, |
| 623 kEthernetMaxBandwidthMbps); | 623 kEthernetMaxBandwidthMbps); |
| 624 RunPendingTasks(); | 624 RunPendingTasks(); |
| 625 EXPECT_TRUE(VerifyObservations( | 625 EXPECT_TRUE(VerifyObservations( |
| 626 observer, kWebConnectionTypeEthernet, kEthernetMaxBandwidthMbps, | 626 observer, kWebConnectionTypeEthernet, kEthernetMaxBandwidthMbps, |
| 627 WebEffectiveConnectionType::kType3G, kUnknownRtt, kEthernetTransportRtt, | 627 WebEffectiveConnectionType::kType3G, kEthernetHttpRtt, kUnknownRtt, |
| 628 kEthernetThroughputMbps)); | 628 kEthernetThroughputMbps)); |
| 629 EXPECT_TRUE(notifier_.OnLine()); | 629 EXPECT_TRUE(notifier_.OnLine()); |
| 630 EXPECT_EQ(kWebConnectionTypeEthernet, notifier_.ConnectionType()); | 630 EXPECT_EQ(kWebConnectionTypeEthernet, notifier_.ConnectionType()); |
| 631 EXPECT_EQ(kEthernetMaxBandwidthMbps, notifier_.MaxBandwidth()); | 631 EXPECT_EQ(kEthernetMaxBandwidthMbps, notifier_.MaxBandwidth()); |
| 632 EXPECT_EQ(WebEffectiveConnectionType::kType3G, notifier_.EffectiveType()); | 632 EXPECT_EQ(WebEffectiveConnectionType::kType3G, notifier_.EffectiveType()); |
| 633 EXPECT_EQ(kEthernetTransportRtt, notifier_.TransportRtt()); | 633 EXPECT_EQ(kEthernetHttpRtt, notifier_.HttpRtt()); |
| 634 EXPECT_EQ(kEthernetThroughputMbps, notifier_.DownlinkThroughputMbps()); | 634 EXPECT_EQ(kEthernetThroughputMbps, notifier_.DownlinkThroughputMbps()); |
| 635 | 635 |
| 636 // CLearing the override should cause the network state to be changed and | 636 // CLearing the override should cause the network state to be changed and |
| 637 // notified to observers. | 637 // notified to observers. |
| 638 notifier_.ClearOverride(); | 638 notifier_.ClearOverride(); |
| 639 RunPendingTasks(); | 639 RunPendingTasks(); |
| 640 EXPECT_TRUE(VerifyObservations( | 640 EXPECT_TRUE(VerifyObservations( |
| 641 observer, kWebConnectionTypeNone, kNoneMaxBandwidthMbps, | 641 observer, kWebConnectionTypeNone, kNoneMaxBandwidthMbps, |
| 642 WebEffectiveConnectionType::kTypeUnknown, kUnknownRtt, kUnknownRtt, | 642 WebEffectiveConnectionType::kTypeUnknown, kUnknownRtt, kUnknownRtt, |
| 643 kUnknownThroughputMbps)); | 643 kUnknownThroughputMbps)); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 WebEffectiveConnectionType::kType3G, kEthernetHttpRtt, | 787 WebEffectiveConnectionType::kType3G, kEthernetHttpRtt, |
| 788 kEthernetTransportRtt, kEthernetThroughputMbps)); | 788 kEthernetTransportRtt, kEthernetThroughputMbps)); |
| 789 EXPECT_EQ(observer1.CallbackCount(), 3); | 789 EXPECT_EQ(observer1.CallbackCount(), 3); |
| 790 EXPECT_EQ(observer2.CallbackCount(), 5); | 790 EXPECT_EQ(observer2.CallbackCount(), 5); |
| 791 | 791 |
| 792 notifier_.RemoveConnectionObserver(&observer1, GetTaskRunner()); | 792 notifier_.RemoveConnectionObserver(&observer1, GetTaskRunner()); |
| 793 notifier_.RemoveConnectionObserver(&observer2, GetTaskRunner()); | 793 notifier_.RemoveConnectionObserver(&observer2, GetTaskRunner()); |
| 794 } | 794 } |
| 795 | 795 |
| 796 } // namespace blink | 796 } // namespace blink |
| OLD | NEW |