Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(477)

Side by Side Diff: third_party/WebKit/Source/core/page/NetworkStateNotifierTest.cpp

Issue 2087293003: [DevTools] Network.emulateNetworkConditions now affects NetworkStateNotifier. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ScopedNotifier Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 m_notifier.addObserver(&observer1, getExecutionContext()); 271 m_notifier.addObserver(&observer1, getExecutionContext());
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 TEST_F(NetworkStateNotifierTest, SetOverride)
282 {
283 StateObserver observer;
284 m_notifier.addObserver(&observer, getExecutionContext());
285
286 m_notifier.setOnLine(true);
287 setConnection(WebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps);
288 EXPECT_TRUE(verifyObservations(observer, WebConnectionTypeBluetooth, kBlueto othMaxBandwidthMbps));
289 EXPECT_TRUE(m_notifier.onLine());
290 EXPECT_EQ(WebConnectionTypeBluetooth, m_notifier.connectionType());
291 EXPECT_EQ(kBluetoothMaxBandwidthMbps, m_notifier.maxBandwidth());
292
293 m_notifier.setOverride(true, WebConnectionTypeEthernet, kEthernetMaxBandwidt hMbps);
294 testing::runPendingTasks();
295 EXPECT_TRUE(verifyObservations(observer, WebConnectionTypeEthernet, kEtherne tMaxBandwidthMbps));
296 EXPECT_TRUE(m_notifier.onLine());
297 EXPECT_EQ(WebConnectionTypeEthernet, m_notifier.connectionType());
298 EXPECT_EQ(kEthernetMaxBandwidthMbps, m_notifier.maxBandwidth());
299
300 // When override is active, calls to setOnLine and setConnection are tempora ry ignored.
301 m_notifier.setOnLine(false);
302 setConnection(WebConnectionTypeNone, kNoneMaxBandwidthMbps);
303 testing::runPendingTasks();
304 EXPECT_TRUE(verifyObservations(observer, WebConnectionTypeEthernet, kEtherne tMaxBandwidthMbps));
305 EXPECT_TRUE(m_notifier.onLine());
306 EXPECT_EQ(WebConnectionTypeEthernet, m_notifier.connectionType());
307 EXPECT_EQ(kEthernetMaxBandwidthMbps, m_notifier.maxBandwidth());
308
309 m_notifier.clearOverride();
310 testing::runPendingTasks();
311 EXPECT_TRUE(verifyObservations(observer, WebConnectionTypeNone, kNoneMaxBand widthMbps));
312 EXPECT_FALSE(m_notifier.onLine());
313 EXPECT_EQ(WebConnectionTypeNone, m_notifier.connectionType());
314 EXPECT_EQ(kNoneMaxBandwidthMbps, m_notifier.maxBandwidth());
315
316 m_notifier.removeObserver(&observer, getExecutionContext());
317 }
318
281 } // namespace blink 319 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698