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..c64395a790e2ec76c9de156c30e6dabb5cffff9e |
--- /dev/null |
+++ b/chrome/browser/sessions/session_restore_test_helper.cc |
@@ -0,0 +1,35 @@ |
+// Copyright (c) 2014 The Chromium Authors. All rights reserved. |
sky
2015/01/26 16:50:01
2015 and no copyright.
Simon Que
2015/01/26 18:40:49
Done.
|
+// 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) { |
+ callback_subscription_ = SessionRestore::RegisterOnSessionRestoredCallback( |
+ base::Bind(&SessionRestoreTestHelper::OnSessionRestoreDone, |
+ base::Unretained(this))); |
sky
2015/01/26 16:50:01
As it's entirely possible for this to be destroyed
Simon Que
2015/01/26 18:40:49
Done.
|
+} |
+ |
+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; |
+} |