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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sessions/session_restore_test_helper.cc
diff --git a/chrome/browser/sessions/session_restore_test_helper.cc b/chrome/browser/sessions/session_restore_test_helper.cc
new file mode 100644
index 0000000000000000000000000000000000000000..678ea992bb6e20c3e410ded7e8fa700906cc59a2
--- /dev/null
+++ b/chrome/browser/sessions/session_restore_test_helper.cc
@@ -0,0 +1,39 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/sessions/session_restore_test_helper.h"
+
+#include "content/public/test/test_utils.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+SessionRestoreTestHelper::SessionRestoreTestHelper()
+ : restore_notification_seen_(false),
+ loop_is_running_(false),
+ weak_ptr_factory(this) {
+ callback_subscription_ = SessionRestore::RegisterOnSessionRestoredCallback(
+ base::Bind(&SessionRestoreTestHelper::OnSessionRestoreDone,
+ weak_ptr_factory.GetWeakPtr()));
+}
+
+SessionRestoreTestHelper::~SessionRestoreTestHelper() {
+}
+
+void SessionRestoreTestHelper::Wait() {
+ if (restore_notification_seen_)
+ return;
+
+ loop_is_running_ = true;
+ message_loop_runner_ = new content::MessageLoopRunner;
+ message_loop_runner_->Run();
+ EXPECT_TRUE(restore_notification_seen_);
+}
+
+void SessionRestoreTestHelper::OnSessionRestoreDone() {
+ restore_notification_seen_ = true;
+ if (!loop_is_running_)
+ return;
+
+ message_loop_runner_->Quit();
+ loop_is_running_ = false;
+}
« 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