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

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
« no previous file with comments | « native_client_sdk/src/tests/nacl_io_test/fake_ppapi/fake_pepper_interface_url_loader.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..9d79e1c5a55502f7f07786048b7231c5bfea9b1f
--- /dev/null
+++ b/native_client_sdk/src/tests/nacl_io_test/host_resolver_test.cc
@@ -0,0 +1,55 @@
+// 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"
+
+using namespace nacl_io;
+using namespace sdk_util;
+
+namespace {
+
+class HostResolverTest : public ::testing::Test {
+ public:
+ HostResolverTest() : pepper_(NULL) {}
+
+ void SetUp() {
+ pepper_ = new FakePepperInterface();
+ ki_init_interface(NULL, pepper_);
+ }
+
+ void TearDown() {
+ ki_uninit();
+ pepper_ = NULL;
+ }
+
+ protected:
+ FakePepperInterface* pepper_;
+};
+
+} // namespace
+
+#define NULL_HOST (static_cast<hostent*>(NULL))
+
+TEST_F(HostResolverTest, GethostbynameNumeric) {
+ hostent* host = ki_gethostbyname(FAKE_HOSTNAME);
+
+ // 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(FAKE_HOSTNAME, 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]);
+ in_addr_t exptected_addr = htonl(FAKE_IP);
+ ASSERT_EQ(exptected_addr, *addr_list[0]);
+}
« no previous file with comments | « native_client_sdk/src/tests/nacl_io_test/fake_ppapi/fake_pepper_interface_url_loader.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698