Index: net/proxy/proxy_config_service_android_unittest.cc |
diff --git a/net/proxy/proxy_config_service_android_unittest.cc b/net/proxy/proxy_config_service_android_unittest.cc |
index 4692553212d5f9d51684cebe58c49ba078dd1231..f1b3ddf7120829b3fe4bc18f3a3de8889a2bf6fc 100644 |
--- a/net/proxy/proxy_config_service_android_unittest.cc |
+++ b/net/proxy/proxy_config_service_android_unittest.cc |
@@ -12,6 +12,7 @@ |
#include "base/compiler_specific.h" |
#include "base/message_loop/message_loop.h" |
#include "base/run_loop.h" |
+#include "jni/AndroidProxyConfigServiceTestUtil_jni.h" |
#include "net/proxy/proxy_config.h" |
#include "net/proxy/proxy_info.h" |
#include "testing/gtest/include/gtest/gtest.h" |
@@ -45,6 +46,15 @@ class TestObserver : public ProxyConfigService::Observer { |
ProxyConfigService::ConfigAvailability availability_; |
}; |
+// Helper class that simply prepares Java's Looper on construction. |
+class JavaLooperPreparer { |
+ public: |
+ JavaLooperPreparer() { |
+ Java_AndroidProxyConfigServiceTestUtil_prepareLooper( |
+ base::android::AttachCurrentThread()); |
+ } |
+}; |
+ |
} // namespace |
typedef std::map<std::string, std::string> StringMap; |
@@ -56,6 +66,9 @@ class ProxyConfigServiceAndroidTestBase : public testing::Test { |
ProxyConfigServiceAndroidTestBase(const StringMap& initial_configuration) |
: configuration_(initial_configuration), |
message_loop_(base::MessageLoop::current()), |
+ // Prepare Java's Looper before constructing |service_| as it creates |
+ // ProxyChangeListener which requires a Looper. |
+ java_looper_preparer_(), |
xunjieli
2017/04/13 18:44:54
hmm.. I guess this isn't safe to omit? I'd assume
pauljensen
2017/05/01 15:35:53
You're right, I think I put it here so the comment
|
service_(message_loop_->task_runner(), |
message_loop_->task_runner(), |
base::Bind(&ProxyConfigServiceAndroidTestBase::GetProperty, |
@@ -104,6 +117,7 @@ class ProxyConfigServiceAndroidTestBase : public testing::Test { |
StringMap configuration_; |
TestObserver observer_; |
base::MessageLoop* const message_loop_; |
+ JavaLooperPreparer java_looper_preparer_; |
ProxyConfigServiceAndroid service_; |
}; |