1 // Copyright 2015 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "services/proxy_resolver/mojo_proxy_resolver_v8_tracing_bindings.h"
11 #include "base/strings/utf_string_conversions.h"
12 #include "testing/gtest/include/gtest/gtest.h"
14 namespace proxy_resolver {
16 class MojoProxyResolverV8TracingBindingsTest : public testing::Test {
18 MojoProxyResolverV8TracingBindingsTest() = default;
20 MojoProxyResolverV8TracingBindingsTest(
21 const MojoProxyResolverV8TracingBindingsTest&) = delete;
22 MojoProxyResolverV8TracingBindingsTest& operator=(
23 const MojoProxyResolverV8TracingBindingsTest&) = delete;
25 void Alert(const std::string& message) { alerts_.push_back(message); }
27 void OnError(int32_t line_number, const std::string& message) {
28 errors_.push_back(std::make_pair(line_number, message));
32 const std::string& hostname,
33 net::ProxyResolveDnsOperation operation,
34 const net::NetworkAnonymizationKey& network_anonymization_key,
35 mojo::PendingRemote<mojom::HostResolverRequestClient> client) {}
38 MojoProxyResolverV8TracingBindings<MojoProxyResolverV8TracingBindingsTest>
41 std::vector<std::string> alerts_;
42 std::vector<std::pair<int, std::string>> errors_;
45 TEST_F(MojoProxyResolverV8TracingBindingsTest, Basic) {
46 bindings_.Alert(u"alert");
47 bindings_.OnError(-1, u"error");
49 EXPECT_TRUE(bindings_.GetHostResolver());
50 EXPECT_FALSE(bindings_.GetNetLogWithSource().net_log());
52 ASSERT_EQ(1u, alerts_.size());
53 EXPECT_EQ("alert", alerts_[0]);
54 ASSERT_EQ(1u, errors_.size());
55 EXPECT_EQ(-1, errors_[0].first);
56 EXPECT_EQ("error", errors_[0].second);
59 } // namespace proxy_resolver