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

Side by Side Diff: mojo/system/dispatcher_unittest.cc

Issue 136343004: Mojo: Add a "GetType()" to Dispatchers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « mojo/system/dispatcher.h ('k') | mojo/system/message_pipe_dispatcher.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/system/dispatcher.h" 5 #include "mojo/system/dispatcher.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_vector.h" 9 #include "base/memory/scoped_vector.h"
10 #include "base/synchronization/waitable_event.h" 10 #include "base/synchronization/waitable_event.h"
11 #include "base/threading/simple_thread.h" 11 #include "base/threading/simple_thread.h"
12 #include "mojo/system/waiter.h" 12 #include "mojo/system/waiter.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 namespace mojo { 15 namespace mojo {
16 namespace system { 16 namespace system {
17 namespace { 17 namespace {
18 18
19 // Trivial subclass that makes the constructor public. 19 // Trivial subclass that makes the constructor public.
20 class TrivialDispatcher : public Dispatcher { 20 class TrivialDispatcher : public Dispatcher {
21 public: 21 public:
22 TrivialDispatcher() {} 22 TrivialDispatcher() {}
23 23
24 virtual Type GetType() OVERRIDE {
25 return kTypeUnknown;
26 }
27
24 private: 28 private:
25 friend class base::RefCountedThreadSafe<TrivialDispatcher>; 29 friend class base::RefCountedThreadSafe<TrivialDispatcher>;
26 virtual ~TrivialDispatcher() {} 30 virtual ~TrivialDispatcher() {}
27 31
28 virtual scoped_refptr<Dispatcher> 32 virtual scoped_refptr<Dispatcher>
29 CreateEquivalentDispatcherAndCloseImplNoLock() OVERRIDE { 33 CreateEquivalentDispatcherAndCloseImplNoLock() OVERRIDE {
30 return scoped_refptr<Dispatcher>(new TrivialDispatcher()); 34 return scoped_refptr<Dispatcher>(new TrivialDispatcher());
31 } 35 }
32 36
33 DISALLOW_COPY_AND_ASSIGN(TrivialDispatcher); 37 DISALLOW_COPY_AND_ASSIGN(TrivialDispatcher);
34 }; 38 };
35 39
36 TEST(DispatcherTest, Basic) { 40 TEST(DispatcherTest, Basic) {
37 scoped_refptr<Dispatcher> d(new TrivialDispatcher()); 41 scoped_refptr<Dispatcher> d(new TrivialDispatcher());
38 42
43 EXPECT_EQ(Dispatcher::kTypeUnknown, d->GetType());
44
39 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, 45 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
40 d->WriteMessage(NULL, 0, NULL, MOJO_WRITE_MESSAGE_FLAG_NONE)); 46 d->WriteMessage(NULL, 0, NULL, MOJO_WRITE_MESSAGE_FLAG_NONE));
41 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, 47 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
42 d->ReadMessage(NULL, NULL, NULL, NULL, 48 d->ReadMessage(NULL, NULL, NULL, NULL,
43 MOJO_WRITE_MESSAGE_FLAG_NONE)); 49 MOJO_WRITE_MESSAGE_FLAG_NONE));
44 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, 50 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
45 d->WriteData(NULL, NULL, MOJO_WRITE_DATA_FLAG_NONE)); 51 d->WriteData(NULL, NULL, MOJO_WRITE_DATA_FLAG_NONE));
46 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, 52 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
47 d->BeginWriteData(NULL, NULL, MOJO_WRITE_DATA_FLAG_NONE)); 53 d->BeginWriteData(NULL, NULL, MOJO_WRITE_DATA_FLAG_NONE));
48 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, 54 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 event.Signal(); // Kicks off real work on the threads. 248 event.Signal(); // Kicks off real work on the threads.
243 } // Joins all the threads. 249 } // Joins all the threads.
244 250
245 EXPECT_EQ(MOJO_RESULT_OK, d->Close()); 251 EXPECT_EQ(MOJO_RESULT_OK, d->Close());
246 } 252 }
247 } 253 }
248 254
249 } // namespace 255 } // namespace
250 } // namespace system 256 } // namespace system
251 } // namespace mojo 257 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/system/dispatcher.h ('k') | mojo/system/message_pipe_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698