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

Side by Side Diff: tests/MessageBusTest.cpp

Issue 902873002: Reimplement gpu message bus for invalidated bitmap gen IDs (Closed) Base URL: https://skia.googlesource.com/skia.git@one_tex
Patch Set: fix speeling error Created 5 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
« no previous file with comments | « src/gpu/SkGr.cpp ('k') | tests/ResourceCacheTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkMessageBus.h" 8 #include "SkMessageBus.h"
9 #include "Test.h" 9 #include "Test.h"
10 10
11 struct TestMessage { 11 struct TestMessage {
12 int x; 12 int x;
13 float y; 13 float y;
14 }; 14 };
15 DECLARE_SKMESSAGEBUS_MESSAGE(TestMessage) 15 DECLARE_SKMESSAGEBUS_MESSAGE(TestMessage)
16 16
17 DEF_TEST(MessageBus, r) { 17 DEF_TEST(MessageBus, r) {
18 // Register two inboxes to receive all TestMessages. 18 // Register two inboxes to receive all TestMessages.
19 SkMessageBus<TestMessage>::Inbox inbox1, inbox2; 19 SkMessageBus<TestMessage>::Inbox inbox1, inbox2;
20 20
21 // Send two messages. 21 // Send two messages.
22 const TestMessage m1 = { 5, 4.2f }; 22 const TestMessage m1 = { 5, 4.2f };
23 const TestMessage m2 = { 6, 4.3f }; 23 const TestMessage m2 = { 6, 4.3f };
24 SkMessageBus<TestMessage>::Post(m1); 24 SkMessageBus<TestMessage>::Post(m1);
25 SkMessageBus<TestMessage>::Post(m2); 25 SkMessageBus<TestMessage>::Post(m2);
26 26
27 // Make sure we got two. 27 // Make sure we got two.
28 SkTDArray<TestMessage> messages; 28 SkTArray<TestMessage> messages;
29 inbox1.poll(&messages); 29 inbox1.poll(&messages);
30 REPORTER_ASSERT(r, 2 == messages.count()); 30 REPORTER_ASSERT(r, 2 == messages.count());
31 REPORTER_ASSERT(r, 5 == messages[0].x); 31 REPORTER_ASSERT(r, 5 == messages[0].x);
32 REPORTER_ASSERT(r, 6 == messages[1].x); 32 REPORTER_ASSERT(r, 6 == messages[1].x);
33 33
34 // Send another; check we get just that one. 34 // Send another; check we get just that one.
35 const TestMessage m3 = { 1, 0.3f }; 35 const TestMessage m3 = { 1, 0.3f };
36 SkMessageBus<TestMessage>::Post(m3); 36 SkMessageBus<TestMessage>::Post(m3);
37 inbox1.poll(&messages); 37 inbox1.poll(&messages);
38 REPORTER_ASSERT(r, 1 == messages.count()); 38 REPORTER_ASSERT(r, 1 == messages.count());
39 REPORTER_ASSERT(r, 1 == messages[0].x); 39 REPORTER_ASSERT(r, 1 == messages[0].x);
40 40
41 // Nothing was sent since the last read. 41 // Nothing was sent since the last read.
42 inbox1.poll(&messages); 42 inbox1.poll(&messages);
43 REPORTER_ASSERT(r, 0 == messages.count()); 43 REPORTER_ASSERT(r, 0 == messages.count());
44 44
45 // Over all this time, inbox2 should have piled up 3 messages. 45 // Over all this time, inbox2 should have piled up 3 messages.
46 inbox2.poll(&messages); 46 inbox2.poll(&messages);
47 REPORTER_ASSERT(r, 3 == messages.count()); 47 REPORTER_ASSERT(r, 3 == messages.count());
48 REPORTER_ASSERT(r, 5 == messages[0].x); 48 REPORTER_ASSERT(r, 5 == messages[0].x);
49 REPORTER_ASSERT(r, 6 == messages[1].x); 49 REPORTER_ASSERT(r, 6 == messages[1].x);
50 REPORTER_ASSERT(r, 1 == messages[2].x); 50 REPORTER_ASSERT(r, 1 == messages[2].x);
51 } 51 }
52 52
53 // Multithreaded tests tbd. 53 // Multithreaded tests tbd.
OLDNEW
« no previous file with comments | « src/gpu/SkGr.cpp ('k') | tests/ResourceCacheTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698