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

Side by Side Diff: mojo/edk/system/platform_handle_dispatcher_unittest.cc

Issue 1915153002: EDK: Add Dispatcher::SupportsEntrypointClass(). (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mojo/edk/system/platform_handle_dispatcher.h" 5 #include "mojo/edk/system/platform_handle_dispatcher.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 fread(read_buffer, 1, sizeof(read_buffer), fp.get())); 53 fread(read_buffer, 1, sizeof(read_buffer), fp.get()));
54 EXPECT_STREQ(kHelloWorld, read_buffer); 54 EXPECT_STREQ(kHelloWorld, read_buffer);
55 55
56 // Try getting the handle again. (It should fail cleanly.) 56 // Try getting the handle again. (It should fail cleanly.)
57 h = dispatcher->PassPlatformHandle(); 57 h = dispatcher->PassPlatformHandle();
58 EXPECT_FALSE(h.is_valid()); 58 EXPECT_FALSE(h.is_valid());
59 59
60 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->Close()); 60 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->Close());
61 } 61 }
62 62
63 TEST(PlatformHandleDispatcher, SupportsEntrypointClass) {
64 test::ScopedTestDir test_dir;
65
66 util::ScopedFILE fp(test_dir.CreateFile());
67 ASSERT_TRUE(fp);
68
69 ScopedPlatformHandle h(PlatformHandleFromFILE(std::move(fp)));
70 EXPECT_FALSE(fp);
71 ASSERT_TRUE(h.is_valid());
72
73 auto d = PlatformHandleDispatcher::Create(h.Pass());
74 ASSERT_TRUE(d);
75 EXPECT_FALSE(h.is_valid());
76
77 EXPECT_FALSE(
78 d->SupportsEntrypointClass(Dispatcher::EntrypointClass::MESSAGE_PIPE));
79 EXPECT_FALSE(d->SupportsEntrypointClass(
80 Dispatcher::EntrypointClass::DATA_PIPE_PRODUCER));
81 EXPECT_FALSE(d->SupportsEntrypointClass(
82 Dispatcher::EntrypointClass::DATA_PIPE_CONSUMER));
83 EXPECT_FALSE(d->SupportsEntrypointClass(Dispatcher::EntrypointClass::BUFFER));
84
85 // TODO(vtl): Check that it actually returns |MOJO_RESULT_INVALID_ARGUMENT|
86 // for methods in unsupported entrypoint classes.
87
88 EXPECT_EQ(MOJO_RESULT_OK, d->Close());
89 }
90
63 TEST(PlatformHandleDispatcherTest, CreateEquivalentDispatcherAndClose) { 91 TEST(PlatformHandleDispatcherTest, CreateEquivalentDispatcherAndClose) {
64 test::ScopedTestDir test_dir; 92 test::ScopedTestDir test_dir;
65 93
66 static const char kFooBar[] = "foo bar"; 94 static const char kFooBar[] = "foo bar";
67 95
68 util::ScopedFILE fp(test_dir.CreateFile()); 96 util::ScopedFILE fp(test_dir.CreateFile());
69 EXPECT_EQ(sizeof(kFooBar), fwrite(kFooBar, 1, sizeof(kFooBar), fp.get())); 97 EXPECT_EQ(sizeof(kFooBar), fwrite(kFooBar, 1, sizeof(kFooBar), fp.get()));
70 98
71 auto dispatcher = 99 auto dispatcher =
72 PlatformHandleDispatcher::Create(PlatformHandleFromFILE(std::move(fp))); 100 PlatformHandleDispatcher::Create(PlatformHandleFromFILE(std::move(fp)));
(...skipping 23 matching lines...) Expand all
96 EXPECT_EQ(sizeof(kFooBar), 124 EXPECT_EQ(sizeof(kFooBar),
97 fread(read_buffer, 1, sizeof(read_buffer), fp.get())); 125 fread(read_buffer, 1, sizeof(read_buffer), fp.get()));
98 EXPECT_STREQ(kFooBar, read_buffer); 126 EXPECT_STREQ(kFooBar, read_buffer);
99 127
100 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->Close()); 128 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->Close());
101 } 129 }
102 130
103 } // namespace 131 } // namespace
104 } // namespace system 132 } // namespace system
105 } // namespace mojo 133 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/platform_handle_dispatcher.cc ('k') | mojo/edk/system/shared_buffer_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698