summaryrefslogtreecommitdiffstats
path: root/mojo/system/local_data_pipe_unittest.cc
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-17 22:38:30 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-17 22:38:30 +0000
commit92fb7f47913d874aa282cab1f81e8d621e637802 (patch)
tree560d6f3d7907f9d3931e89e1216962b81716cab9 /mojo/system/local_data_pipe_unittest.cc
parent5d0bf8b3808efe91dc8bf8cf44583796e3d3aa02 (diff)
downloadchromium_src-92fb7f47913d874aa282cab1f81e8d621e637802.zip
chromium_src-92fb7f47913d874aa282cab1f81e8d621e637802.tar.gz
chromium_src-92fb7f47913d874aa282cab1f81e8d621e637802.tar.bz2
Mojo: Refactor (local) data pipe creation/initialization.
- Separate out the validation of options. - Remove |Init()|. Now you can create the LocalDataPipe with your validated options. - Once created, the LocalDataPipe has to be shut down correctly. (This was true before, but broken -- if you ran out of handles in MojoCreateDataPipe(), DCHECKs would fire.) - Add tests for the new |DataPipe::ValidateOptions()|. - Also add a minimal test for LocalDataPipe creation (which led to the discovery of the above bug, and consequently the above refactoring). - Change the struct_size field of options to a |uint32_t|. This makes it much easier to reason about the size of the struct, which we need to be careful about. R=sky@chromium.org Review URL: https://codereview.chromium.org/116573010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@241393 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo/system/local_data_pipe_unittest.cc')
-rw-r--r--mojo/system/local_data_pipe_unittest.cc35
1 files changed, 35 insertions, 0 deletions
diff --git a/mojo/system/local_data_pipe_unittest.cc b/mojo/system/local_data_pipe_unittest.cc
new file mode 100644
index 0000000..ad699a9
--- /dev/null
+++ b/mojo/system/local_data_pipe_unittest.cc
@@ -0,0 +1,35 @@
+// Copyright 2013 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 "mojo/system/local_data_pipe.h"
+
+#include "base/memory/ref_counted.h"
+#include "mojo/system/data_pipe.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace mojo {
+namespace system {
+namespace {
+
+// Validate options.
+TEST(LocalDataPipeTest, Creation) {
+ // Get default options.
+ MojoCreateDataPipeOptions default_options = { 0 };
+ EXPECT_EQ(MOJO_RESULT_OK, DataPipe::ValidateOptions(NULL, &default_options));
+
+ // Create using default options.
+ {
+ scoped_refptr<LocalDataPipe> dp(new LocalDataPipe(default_options));
+ dp->ProducerClose();
+ dp->ConsumerClose();
+ }
+
+ // TODO(vtl): More.
+}
+
+// TODO(vtl): More.
+
+} // namespace
+} // namespace system
+} // namespace mojo