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

Side by Side Diff: base/message_loop/message_loop_unittest.cc

Issue 2283003002: Remove unneeded scoped_refptr<>::get on method bind (Closed)
Patch Set: update Created 4 years, 3 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 | « base/message_loop/message_loop_test.cc ('k') | base/message_loop/message_pump_glib_unittest.cc » ('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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 861
862 862
863 // Verify that MessageLoop sets ThreadMainTaskRunner::current() and it 863 // Verify that MessageLoop sets ThreadMainTaskRunner::current() and it
864 // posts tasks on that message loop. 864 // posts tasks on that message loop.
865 TEST(MessageLoopTest, ThreadMainTaskRunner) { 865 TEST(MessageLoopTest, ThreadMainTaskRunner) {
866 MessageLoop loop; 866 MessageLoop loop;
867 867
868 scoped_refptr<Foo> foo(new Foo()); 868 scoped_refptr<Foo> foo(new Foo());
869 std::string a("a"); 869 std::string a("a");
870 ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, Bind( 870 ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, Bind(
871 &Foo::Test1ConstRef, foo.get(), a)); 871 &Foo::Test1ConstRef, foo, a));
872 872
873 // Post quit task; 873 // Post quit task;
874 MessageLoop::current()->task_runner()->PostTask( 874 MessageLoop::current()->task_runner()->PostTask(
875 FROM_HERE, 875 FROM_HERE,
876 Bind(&MessageLoop::QuitWhenIdle, Unretained(MessageLoop::current()))); 876 Bind(&MessageLoop::QuitWhenIdle, Unretained(MessageLoop::current())));
877 877
878 // Now kick things off 878 // Now kick things off
879 RunLoop().Run(); 879 RunLoop().Run();
880 880
881 EXPECT_EQ(foo->test_count(), 1); 881 EXPECT_EQ(foo->test_count(), 1);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 } 990 }
991 991
992 TEST(MessageLoopTest, OriginalRunnerWorks) { 992 TEST(MessageLoopTest, OriginalRunnerWorks) {
993 MessageLoop loop; 993 MessageLoop loop;
994 scoped_refptr<SingleThreadTaskRunner> new_runner(new TestSimpleTaskRunner()); 994 scoped_refptr<SingleThreadTaskRunner> new_runner(new TestSimpleTaskRunner());
995 scoped_refptr<SingleThreadTaskRunner> original_runner(loop.task_runner()); 995 scoped_refptr<SingleThreadTaskRunner> original_runner(loop.task_runner());
996 loop.SetTaskRunner(new_runner); 996 loop.SetTaskRunner(new_runner);
997 997
998 scoped_refptr<Foo> foo(new Foo()); 998 scoped_refptr<Foo> foo(new Foo());
999 original_runner->PostTask(FROM_HERE, 999 original_runner->PostTask(FROM_HERE,
1000 Bind(&Foo::Test1ConstRef, foo.get(), "a")); 1000 Bind(&Foo::Test1ConstRef, foo, "a"));
1001 RunLoop().RunUntilIdle(); 1001 RunLoop().RunUntilIdle();
1002 EXPECT_EQ(1, foo->test_count()); 1002 EXPECT_EQ(1, foo->test_count());
1003 } 1003 }
1004 1004
1005 TEST(MessageLoopTest, DeleteUnboundLoop) { 1005 TEST(MessageLoopTest, DeleteUnboundLoop) {
1006 // It should be possible to delete an unbound message loop on a thread which 1006 // It should be possible to delete an unbound message loop on a thread which
1007 // already has another active loop. This happens when thread creation fails. 1007 // already has another active loop. This happens when thread creation fails.
1008 MessageLoop loop; 1008 MessageLoop loop;
1009 std::unique_ptr<MessageLoop> unbound_loop(MessageLoop::CreateUnbound( 1009 std::unique_ptr<MessageLoop> unbound_loop(MessageLoop::CreateUnbound(
1010 MessageLoop::TYPE_DEFAULT, MessageLoop::MessagePumpFactoryCallback())); 1010 MessageLoop::TYPE_DEFAULT, MessageLoop::MessagePumpFactoryCallback()));
(...skipping 12 matching lines...) Expand all
1023 1023
1024 { 1024 {
1025 std::string kThreadName("bar"); 1025 std::string kThreadName("bar");
1026 base::Thread thread(kThreadName); 1026 base::Thread thread(kThreadName);
1027 ASSERT_TRUE(thread.StartAndWaitForTesting()); 1027 ASSERT_TRUE(thread.StartAndWaitForTesting());
1028 EXPECT_EQ(kThreadName, thread.message_loop()->GetThreadName()); 1028 EXPECT_EQ(kThreadName, thread.message_loop()->GetThreadName());
1029 } 1029 }
1030 } 1030 }
1031 1031
1032 } // namespace base 1032 } // namespace base
OLDNEW
« no previous file with comments | « base/message_loop/message_loop_test.cc ('k') | base/message_loop/message_pump_glib_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698