| 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 observer->setNotificationCallback(bind(&NetworkStateNotifier::removeObse
rver, &m_notifier, observerToRemove, getExecutionContext())); | 127 observer->setNotificationCallback(bind(&NetworkStateNotifier::removeObse
rver, &m_notifier, observerToRemove, getExecutionContext())); |
| 128 } | 128 } |
| 129 | 129 |
| 130 bool verifyObservations(const StateObserver& observer, WebConnectionType typ
e, double maxBandwidthMbps) | 130 bool verifyObservations(const StateObserver& observer, WebConnectionType typ
e, double maxBandwidthMbps) |
| 131 { | 131 { |
| 132 EXPECT_EQ(observer.observedType(), type); | 132 EXPECT_EQ(observer.observedType(), type); |
| 133 EXPECT_EQ(observer.observedMaxBandwidth(), maxBandwidthMbps); | 133 EXPECT_EQ(observer.observedMaxBandwidth(), maxBandwidthMbps); |
| 134 return observer.observedType() == type && observer.observedMaxBandwidth(
) == maxBandwidthMbps; | 134 return observer.observedType() == type && observer.observedMaxBandwidth(
) == maxBandwidthMbps; |
| 135 } | 135 } |
| 136 | 136 |
| 137 RefPtrWillBePersistent<Document> m_document; | 137 Persistent<Document> m_document; |
| 138 RefPtrWillBePersistent<Document> m_document2; | 138 Persistent<Document> m_document2; |
| 139 NetworkStateNotifier m_notifier; | 139 NetworkStateNotifier m_notifier; |
| 140 }; | 140 }; |
| 141 | 141 |
| 142 TEST_F(NetworkStateNotifierTest, AddObserver) | 142 TEST_F(NetworkStateNotifierTest, AddObserver) |
| 143 { | 143 { |
| 144 StateObserver observer; | 144 StateObserver observer; |
| 145 m_notifier.addObserver(&observer, getExecutionContext()); | 145 m_notifier.addObserver(&observer, getExecutionContext()); |
| 146 EXPECT_TRUE(verifyObservations(observer, WebConnectionTypeNone, kNoneMaxBand
widthMbps)); | 146 EXPECT_TRUE(verifyObservations(observer, WebConnectionTypeNone, kNoneMaxBand
widthMbps)); |
| 147 | 147 |
| 148 setConnection(WebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps); | 148 setConnection(WebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 m_notifier.addObserver(&observer2, executionContext2()); | 272 m_notifier.addObserver(&observer2, executionContext2()); |
| 273 m_notifier.removeObserver(&observer1, getExecutionContext()); | 273 m_notifier.removeObserver(&observer1, getExecutionContext()); |
| 274 m_notifier.removeObserver(&observer2, executionContext2()); | 274 m_notifier.removeObserver(&observer2, executionContext2()); |
| 275 | 275 |
| 276 setConnection(WebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps); | 276 setConnection(WebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps); |
| 277 EXPECT_TRUE(verifyObservations(observer1, WebConnectionTypeNone, kNoneMaxBan
dwidthMbps)); | 277 EXPECT_TRUE(verifyObservations(observer1, WebConnectionTypeNone, kNoneMaxBan
dwidthMbps)); |
| 278 EXPECT_TRUE(verifyObservations(observer2, WebConnectionTypeNone, kNoneMaxBan
dwidthMbps)); | 278 EXPECT_TRUE(verifyObservations(observer2, WebConnectionTypeNone, kNoneMaxBan
dwidthMbps)); |
| 279 } | 279 } |
| 280 | 280 |
| 281 } // namespace blink | 281 } // namespace blink |
| OLD | NEW |