Index: chrome/browser/chromeos/login/test/app_window_waiter.cc |
diff --git a/chrome/browser/chromeos/login/test/app_window_waiter.cc b/chrome/browser/chromeos/login/test/app_window_waiter.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..fb8b5ad44e139ced1e852b44afc443730837b583 |
--- /dev/null |
+++ b/chrome/browser/chromeos/login/test/app_window_waiter.cc |
@@ -0,0 +1,47 @@ |
+// Copyright 2014 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/chromeos/login/test/app_window_waiter.h" |
+ |
+#include "apps/app_window.h" |
+#include "content/public/test/test_utils.h" |
bartfab (slow)
2014/03/27 14:13:29
Nit: Not used.
rkc
2014/03/27 21:43:10
Done.
|
+#include "testing/gtest/include/gtest/gtest.h" |
bartfab (slow)
2014/03/27 14:13:29
Nit: Not used.
rkc
2014/03/27 21:43:10
Done.
|
+ |
+namespace chromeos { |
+ |
+AppWindowWaiter::AppWindowWaiter(apps::AppWindowRegistry* registry, |
+ const std::string& app_id) |
+ : registry_(registry), app_id_(app_id), window_(NULL) { |
+ registry_->AddObserver(this); |
+} |
+ |
+AppWindowWaiter::~AppWindowWaiter() { |
+ registry_->RemoveObserver(this); |
+} |
+ |
+apps::AppWindow* AppWindowWaiter::Wait() { |
+ window_ = registry_->GetCurrentAppWindowForApp(app_id_); |
+ if (window_) |
+ return window_; |
+ |
+ run_loop_.Run(); |
+ |
+ return window_; |
+} |
+ |
+void AppWindowWaiter::OnAppWindowAdded(apps::AppWindow* app_window) { |
+ if (!run_loop_.running()) |
+ return; |
+ |
+ if (app_window->extension_id() == app_id_) { |
+ window_ = app_window; |
+ run_loop_.Quit(); |
+ } |
+} |
+ |
+void AppWindowWaiter::OnAppWindowIconChanged(apps::AppWindow* app_window) {} |
+ |
+void AppWindowWaiter::OnAppWindowRemoved(apps::AppWindow* app_window) {} |
+ |
+} // namespace chromeos |