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
3 // found in the LICENSE file.
5 #include "net/proxy/mojo_proxy_resolver_v8_tracing_bindings.h"
11 #include "base/strings/utf_string_conversions.h"
12 #include "testing/gtest/include/gtest/gtest.h"
16 class MojoProxyResolverV8TracingBindingsTest
: public testing::Test
{
18 MojoProxyResolverV8TracingBindingsTest() = default;
20 void SetUp() override
{
21 bindings_
.reset(new MojoProxyResolverV8TracingBindings
<
22 MojoProxyResolverV8TracingBindingsTest
>(this));
25 void Alert(const mojo::String
& message
) {
26 alerts_
.push_back(message
.To
<std::string
>());
29 void OnError(int32_t line_number
, const mojo::String
& message
) {
30 errors_
.push_back(std::make_pair(line_number
, message
.To
<std::string
>()));
33 void ResolveDns(interfaces::HostResolverRequestInfoPtr request_info
,
34 interfaces::HostResolverRequestClientPtr client
) {}
37 scoped_ptr
<MojoProxyResolverV8TracingBindings
<
38 MojoProxyResolverV8TracingBindingsTest
>> bindings_
;
40 std::vector
<std::string
> alerts_
;
41 std::vector
<std::pair
<int, std::string
>> errors_
;
44 DISALLOW_COPY_AND_ASSIGN(MojoProxyResolverV8TracingBindingsTest
);
47 TEST_F(MojoProxyResolverV8TracingBindingsTest
, Basic
) {
48 bindings_
->Alert(base::ASCIIToUTF16("alert"));
49 bindings_
->OnError(-1, base::ASCIIToUTF16("error"));
51 EXPECT_TRUE(bindings_
->GetHostResolver());
52 EXPECT_FALSE(bindings_
->GetBoundNetLog().net_log());
54 ASSERT_EQ(1u, alerts_
.size());
55 EXPECT_EQ("alert", alerts_
[0]);
56 ASSERT_EQ(1u, errors_
.size());
57 EXPECT_EQ(-1, errors_
[0].first
);
58 EXPECT_EQ("error", errors_
[0].second
);