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

Side by Side Diff: chrome/browser/sync_file_system/drive_backend/callback_helper_unittest.cc

Issue 259503004: [SyncFS] Refine callback helpers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
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 "chrome/browser/sync_file_system/drive_backend/callback_helper.h" 5 #include "chrome/browser/sync_file_system/drive_backend/callback_helper.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 namespace sync_file_system { 11 namespace sync_file_system {
12 namespace drive_backend { 12 namespace drive_backend {
13 13
14 namespace { 14 namespace {
15 15
16 void SimpleCallback(bool* called, int) { 16 void SimpleCallback(bool* called, int) {
17 ASSERT_TRUE(called); 17 ASSERT_TRUE(called);
18 EXPECT_FALSE(*called); 18 EXPECT_FALSE(*called);
19 *called = true; 19 *called = true;
20 } 20 }
21 21
22 void CallbackWithPassed(bool* called, scoped_ptr<int>) { 22 void CallbackWithPassed(bool* called, scoped_ptr<int>) {
23 ASSERT_TRUE(called); 23 ASSERT_TRUE(called);
24 EXPECT_FALSE(*called); 24 EXPECT_FALSE(*called);
25 *called = true; 25 *called = true;
26 } 26 }
27 27
28 } // namespace 28 } // namespace
29 29
30 TEST(DriveBackendCallbackHelperTest, CreateRelayedCallbackTest) { 30 TEST(DriveBackendCallbackHelperTest, RelayCallbackToCurrentThreadTest) {
peria 2014/04/24 05:13:53 Please add a test case for void(void) function.
tzik 2014/04/24 07:02:17 Done.
31 base::MessageLoop message_loop; 31 base::MessageLoop message_loop;
32 32
33 bool called = false; 33 bool called = false;
34 CreateRelayedCallback(base::Bind(&SimpleCallback, &called)).Run(0); 34 RelayCallbackToCurrentThread(
35 FROM_HERE,
36 base::Bind(&SimpleCallback, &called)).Run(0);
35 EXPECT_FALSE(called); 37 EXPECT_FALSE(called);
36 base::RunLoop().RunUntilIdle(); 38 base::RunLoop().RunUntilIdle();
37 EXPECT_TRUE(called); 39 EXPECT_TRUE(called);
38 40
39 called = false; 41 called = false;
40 CreateRelayedCallback( 42 RelayCallbackToCurrentThread(
43 FROM_HERE,
41 base::Bind(&CallbackWithPassed, &called)) 44 base::Bind(&CallbackWithPassed, &called))
42 .Run(scoped_ptr<int>(new int)); 45 .Run(scoped_ptr<int>(new int));
43 EXPECT_FALSE(called); 46 EXPECT_FALSE(called);
44 base::RunLoop().RunUntilIdle(); 47 base::RunLoop().RunUntilIdle();
45 EXPECT_TRUE(called); 48 EXPECT_TRUE(called);
46 } 49 }
47 50
48 } // namespace drive_backend 51 } // namespace drive_backend
49 } // namespace sync_file_system 52 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698