| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/proxy/mojo_proxy_resolver_factory_impl.h" | 5 #include "net/proxy/mojo_proxy_resolver_factory_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "mojo/public/cpp/bindings/binding.h" | 11 #include "mojo/public/cpp/bindings/binding.h" |
| 12 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 12 #include "net/base/test_completion_callback.h" | 13 #include "net/base/test_completion_callback.h" |
| 13 #include "net/proxy/mock_proxy_resolver.h" | 14 #include "net/proxy/mock_proxy_resolver.h" |
| 14 #include "net/proxy/proxy_resolver_v8_tracing.h" | 15 #include "net/proxy/proxy_resolver_v8_tracing.h" |
| 15 #include "net/test/event_waiter.h" | 16 #include "net/test/event_waiter.h" |
| 16 #include "net/test/gtest_util.h" | 17 #include "net/test/gtest_util.h" |
| 17 #include "testing/gmock/include/gmock/gmock.h" | 18 #include "testing/gmock/include/gmock/gmock.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 20 |
| 20 using net::test::IsError; | 21 using net::test::IsError; |
| 21 using net::test::IsOk; | 22 using net::test::IsOk; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 }; | 98 }; |
| 98 | 99 |
| 99 } // namespace | 100 } // namespace |
| 100 | 101 |
| 101 class MojoProxyResolverFactoryImplTest | 102 class MojoProxyResolverFactoryImplTest |
| 102 : public testing::Test, | 103 : public testing::Test, |
| 103 public interfaces::ProxyResolverFactoryRequestClient { | 104 public interfaces::ProxyResolverFactoryRequestClient { |
| 104 public: | 105 public: |
| 105 void SetUp() override { | 106 void SetUp() override { |
| 106 mock_factory_ = new TestProxyResolverFactory(&waiter_); | 107 mock_factory_ = new TestProxyResolverFactory(&waiter_); |
| 107 new MojoProxyResolverFactoryImpl(base::WrapUnique(mock_factory_), | 108 mojo::MakeStrongBinding(base::MakeUnique<MojoProxyResolverFactoryImpl>( |
| 108 mojo::GetProxy(&factory_)); | 109 base::WrapUnique(mock_factory_)), |
| 110 mojo::GetProxy(&factory_)); |
| 109 } | 111 } |
| 110 | 112 |
| 111 void OnConnectionError() { waiter_.NotifyEvent(CONNECTION_ERROR); } | 113 void OnConnectionError() { waiter_.NotifyEvent(CONNECTION_ERROR); } |
| 112 | 114 |
| 113 void OnFakeProxyInstanceDestroyed() { | 115 void OnFakeProxyInstanceDestroyed() { |
| 114 instances_destroyed_++; | 116 instances_destroyed_++; |
| 115 waiter_.NotifyEvent(RESOLVER_DESTROYED); | 117 waiter_.NotifyEvent(RESOLVER_DESTROYED); |
| 116 } | 118 } |
| 117 | 119 |
| 118 void ReportResult(int32_t error) override { create_callback_.Run(error); } | 120 void ReportResult(int32_t error) override { create_callback_.Run(error); } |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 base::Bind(&MojoProxyResolverFactoryImplTest::OnConnectionError, | 221 base::Bind(&MojoProxyResolverFactoryImplTest::OnConnectionError, |
| 220 base::Unretained(this))); | 222 base::Unretained(this))); |
| 221 waiter_.WaitForEvent(RESOLVER_CREATED); | 223 waiter_.WaitForEvent(RESOLVER_CREATED); |
| 222 EXPECT_EQ(0, instances_destroyed_); | 224 EXPECT_EQ(0, instances_destroyed_); |
| 223 ASSERT_EQ(1u, mock_factory_->requests_handled()); | 225 ASSERT_EQ(1u, mock_factory_->requests_handled()); |
| 224 factory_.reset(); | 226 factory_.reset(); |
| 225 waiter_.WaitForEvent(CONNECTION_ERROR); | 227 waiter_.WaitForEvent(CONNECTION_ERROR); |
| 226 } | 228 } |
| 227 | 229 |
| 228 } // namespace net | 230 } // namespace net |
| OLD | NEW |