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

Unified Diff: native_client_sdk/src/tests/nacl_io_test/host_resolver_test.cc

Issue 148223005: [NaCl SDK] Add fake for ppb_host_resolver and ppb_net_address (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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: native_client_sdk/src/tests/nacl_io_test/host_resolver_test.cc
diff --git a/native_client_sdk/src/tests/nacl_io_test/host_resolver_test.cc b/native_client_sdk/src/tests/nacl_io_test/host_resolver_test.cc
new file mode 100644
index 0000000000000000000000000000000000000000..61a97301a4146ba71e3eb6ebe15c87ae7d1da228
--- /dev/null
+++ b/native_client_sdk/src/tests/nacl_io_test/host_resolver_test.cc
@@ -0,0 +1,60 @@
+// 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 <arpa/inet.h>
+#include <netinet/in.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#include "fake_ppapi/fake_pepper_interface.h"
+#include "gtest/gtest.h"
+#include "nacl_io/kernel_intercept.h"
+#include "nacl_io/kernel_proxy.h"
+
+using namespace nacl_io;
+using namespace sdk_util;
+
+namespace {
+
+//class FakeKernelProxy : public KernelProxy {
binji 2014/01/28 18:13:22 remove
Sam Clegg 2014/01/28 19:55:22 Done.
+//};
+
+class HostResolverTest : public ::testing::Test {
+ public:
+ HostResolverTest() : pepper_(NULL) {}
+
+ void SetUp() {
+ pepper_ = new FakePepperInterface();
+ ki_init_interface(&proxy_, pepper_);
+ }
+
+ void TearDown() {
+ ki_uninit();
+ pepper_ = NULL;
+ }
+
+ protected:
+ //FakeKernelProxy fake_proxy_;
binji 2014/01/28 18:13:22 remove
Sam Clegg 2014/01/28 19:55:22 Done.
+ KernelProxy proxy_;
+ FakePepperInterface* pepper_;
+};
+
+} // namespace
+
+#define NULL_HOST (static_cast<hostent*>(NULL))
+
+TEST_F(HostResolverTest, GethostbynameNumeric) {
+ hostent* host = ki_gethostbyname("testhost.com");
+
+ // Verify the returned hostent structure
+ ASSERT_NE(NULL_HOST, host);
+ ASSERT_EQ(AF_INET, host->h_addrtype);
+ ASSERT_EQ(sizeof(in_addr_t), host->h_length);
+ ASSERT_STREQ("testhost.com", host->h_name);
+
+ in_addr_t** addr_list = reinterpret_cast<in_addr_t**>(host->h_addr_list);
+ ASSERT_NE(reinterpret_cast<in_addr_t**>(NULL), addr_list);
+ ASSERT_EQ(NULL, addr_list[1]);
+ ASSERT_EQ(inet_addr("1.2.3.4"), *addr_list[0]);
+}

Powered by Google App Engine
This is Rietveld 408576698