OLD | NEW |
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 "gin/modules/timer.h" | 5 #include "gin/modules/timer.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include <memory> |
| 8 |
8 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
9 #include "gin/handle.h" | 10 #include "gin/handle.h" |
10 #include "gin/object_template_builder.h" | 11 #include "gin/object_template_builder.h" |
11 #include "gin/public/isolate_holder.h" | 12 #include "gin/public/isolate_holder.h" |
12 #include "gin/shell_runner.h" | 13 #include "gin/shell_runner.h" |
13 #include "gin/test/v8_test.h" | 14 #include "gin/test/v8_test.h" |
14 #include "gin/try_catch.h" | 15 #include "gin/try_catch.h" |
15 #include "gin/wrappable.h" | 16 #include "gin/wrappable.h" |
16 #include "v8/include/v8.h" | 17 #include "v8/include/v8.h" |
17 | 18 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 result->GetWrapper(isolate)); | 65 result->GetWrapper(isolate)); |
65 } | 66 } |
66 | 67 |
67 void QuitSoon(base::MessageLoop* message_loop) { | 68 void QuitSoon(base::MessageLoop* message_loop) { |
68 message_loop->PostDelayedTask(FROM_HERE, | 69 message_loop->PostDelayedTask(FROM_HERE, |
69 base::MessageLoop::QuitWhenIdleClosure(), | 70 base::MessageLoop::QuitWhenIdleClosure(), |
70 base::TimeDelta::FromMilliseconds(0)); | 71 base::TimeDelta::FromMilliseconds(0)); |
71 } | 72 } |
72 | 73 |
73 ShellRunnerDelegate delegate; | 74 ShellRunnerDelegate delegate; |
74 scoped_ptr<ShellRunner> runner; | 75 std::unique_ptr<ShellRunner> runner; |
75 Runner::Scope scope; | 76 Runner::Scope scope; |
76 Handle<TimerModule> timer_module; | 77 Handle<TimerModule> timer_module; |
77 Handle<Result> result; | 78 Handle<Result> result; |
78 }; | 79 }; |
79 | 80 |
80 } // namespace | 81 } // namespace |
81 | 82 |
82 typedef V8Test TimerUnittest; | 83 typedef V8Test TimerUnittest; |
83 | 84 |
84 TEST_F(TimerUnittest, OneShot) { | 85 TEST_F(TimerUnittest, OneShot) { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 // Destroy runner, which should destroy the timer object we created. | 146 // Destroy runner, which should destroy the timer object we created. |
146 helper.QuitSoon(&message_loop_); | 147 helper.QuitSoon(&message_loop_); |
147 helper.runner.reset(NULL); | 148 helper.runner.reset(NULL); |
148 message_loop_.Run(); | 149 message_loop_.Run(); |
149 | 150 |
150 // Timer should not have run because it was deleted. | 151 // Timer should not have run because it was deleted. |
151 EXPECT_EQ(0, helper.result->count()); | 152 EXPECT_EQ(0, helper.result->count()); |
152 } | 153 } |
153 | 154 |
154 } // namespace gin | 155 } // namespace gin |
OLD | NEW |