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

Unified Diff: apps/test/app_window_waiter.cc

Issue 2576353002: Make AppWindowWaiter a common test support (Closed)
Patch Set: nits Created 4 years 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 | « apps/test/app_window_waiter.h ('k') | chrome/browser/chromeos/app_mode/kiosk_crash_restore_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: apps/test/app_window_waiter.cc
diff --git a/chrome/browser/chromeos/login/test/app_window_waiter.cc b/apps/test/app_window_waiter.cc
similarity index 69%
rename from chrome/browser/chromeos/login/test/app_window_waiter.cc
rename to apps/test/app_window_waiter.cc
index 0308b7d2b598fbe5f887d9b50065924997f3f224..beae24c2cdde4f3d2d465efef687606f22d2bddd 100644
--- a/chrome/browser/chromeos/login/test/app_window_waiter.cc
+++ b/apps/test/app_window_waiter.cc
@@ -2,11 +2,12 @@
// 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/test/app_window_waiter.h"
#include "extensions/browser/app_window/app_window.h"
+#include "extensions/browser/app_window/native_app_window.h"
-namespace chromeos {
+namespace apps {
AppWindowWaiter::AppWindowWaiter(extensions::AppWindowRegistry* registry,
const std::string& app_id)
@@ -42,6 +43,18 @@ extensions::AppWindow* AppWindowWaiter::WaitForShown() {
return window_;
}
+extensions::AppWindow* AppWindowWaiter::WaitForActivated() {
+ window_ = registry_->GetCurrentAppWindowForApp(app_id_);
+ if (window_ && window_->GetBaseWindow()->IsActive())
+ return window_;
+
+ wait_type_ = WAIT_FOR_ACTIVATED;
+ run_loop_.reset(new base::RunLoop);
+ run_loop_->Run();
+
+ return window_;
+}
+
void AppWindowWaiter::OnAppWindowAdded(extensions::AppWindow* app_window) {
if (wait_type_ != WAIT_FOR_ADDED || !run_loop_ || !run_loop_->running())
return;
@@ -63,4 +76,14 @@ void AppWindowWaiter::OnAppWindowShown(extensions::AppWindow* app_window,
}
}
-} // namespace chromeos
+void AppWindowWaiter::OnAppWindowActivated(extensions::AppWindow* app_window) {
+ if (wait_type_ != WAIT_FOR_ACTIVATED || !run_loop_ || !run_loop_->running())
+ return;
+
+ if (app_window->extension_id() == app_id_) {
+ window_ = app_window;
+ run_loop_->Quit();
+ }
+}
+
+} // namespace apps
« no previous file with comments | « apps/test/app_window_waiter.h ('k') | chrome/browser/chromeos/app_mode/kiosk_crash_restore_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698