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

Unified Diff: components/cronet/android/test/network_change_notifier_util.cc

Issue 2406273002: [Cronet] Test the libcronet that's shipped, not libcronet_test (Closed)
Patch Set: address two remaining comments Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: components/cronet/android/test/network_change_notifier_util.cc
diff --git a/components/cronet/android/test/network_change_notifier_util.cc b/components/cronet/android/test/network_change_notifier_util.cc
deleted file mode 100644
index a13afa1732623d1f493b2e7db01418abfb5b9a69..0000000000000000000000000000000000000000
--- a/components/cronet/android/test/network_change_notifier_util.cc
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "network_change_notifier_util.h"
-
-#include "base/android/jni_android.h"
-#include "base/macros.h"
-#include "base/message_loop/message_loop.h"
-#include "base/run_loop.h"
-#include "jni/NetworkChangeNotifierUtil_jni.h"
-#include "net/base/network_change_notifier.h"
-
-using base::android::JavaParamRef;
-
-namespace cronet {
-
-namespace {
-
-// An IPAddressObserver to test whether Cronet can receive notification
-// when network changes.
-class TestIPAddressObserver
- : public net::NetworkChangeNotifier::IPAddressObserver {
- public:
- TestIPAddressObserver() : ip_address_changed_(false) {
- }
-
- ~TestIPAddressObserver() override {}
-
- // net::NetworkChangeNotifier::IPAddressObserver implementation.
- void OnIPAddressChanged() override {
- ip_address_changed_ = true;
- }
-
- bool ip_address_changed() const {
- return ip_address_changed_;
- }
-
- private:
- bool ip_address_changed_;
-
- DISALLOW_COPY_AND_ASSIGN(TestIPAddressObserver);
-};
-
-} // namespace
-
-// Adds a TestIPAddressObserver to the list of IPAddressObservers, and returns
-// a boolean indicating whether the TestIPAddressObserver has received
-// notification when network changes.
-static jboolean IsTestIPAddressObserverCalled(
- JNIEnv* jenv,
- const JavaParamRef<jclass>& jcaller) {
- // This method is called on a Java thread with no MessageLoop, but we need
- // one for the NetworkChangeNotifier to call the observer on.
- base::MessageLoop loop;
- TestIPAddressObserver test_observer;
- net::NetworkChangeNotifier::AddIPAddressObserver(&test_observer);
- net::NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests();
-
- base::RunLoop().RunUntilIdle();
- net::NetworkChangeNotifier::RemoveIPAddressObserver(&test_observer);
-
- return test_observer.ip_address_changed();
-}
-
-bool RegisterNetworkChangeNotifierUtil(JNIEnv* jenv) {
- return RegisterNativesImpl(jenv);
-}
-
-} // namespace cronet

Powered by Google App Engine
This is Rietveld 408576698