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

Side by Side Diff: chrome/browser/sessions/session_restore_test_helper.cc

Issue 871013006: Use callbacks in SessionRestore unit tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add destructor Created 5 years, 11 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 | « chrome/browser/sessions/session_restore_test_helper.h ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/sessions/session_restore_test_helper.h"
6
7 #include "content/public/test/test_utils.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 SessionRestoreTestHelper::SessionRestoreTestHelper()
11 : restore_notification_seen_(false),
12 loop_is_running_(false),
13 weak_ptr_factory(this) {
14 callback_subscription_ = SessionRestore::RegisterOnSessionRestoredCallback(
15 base::Bind(&SessionRestoreTestHelper::OnSessionRestoreDone,
16 weak_ptr_factory.GetWeakPtr()));
17 }
18
19 SessionRestoreTestHelper::~SessionRestoreTestHelper() {
20 }
21
22 void SessionRestoreTestHelper::Wait() {
23 if (restore_notification_seen_)
24 return;
25
26 loop_is_running_ = true;
27 message_loop_runner_ = new content::MessageLoopRunner;
28 message_loop_runner_->Run();
29 EXPECT_TRUE(restore_notification_seen_);
30 }
31
32 void SessionRestoreTestHelper::OnSessionRestoreDone() {
33 restore_notification_seen_ = true;
34 if (!loop_is_running_)
35 return;
36
37 message_loop_runner_->Quit();
38 loop_is_running_ = false;
39 }
OLDNEW
« no previous file with comments | « chrome/browser/sessions/session_restore_test_helper.h ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698