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

Unified Diff: chrome/test/chromedriver/chrome/chrome_desktop_impl.cc

Issue 1196663005: [chromedriver] When launching a Chrome App, automatically switch to the new window. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
Index: chrome/test/chromedriver/chrome/chrome_desktop_impl.cc
diff --git a/chrome/test/chromedriver/chrome/chrome_desktop_impl.cc b/chrome/test/chromedriver/chrome/chrome_desktop_impl.cc
index 3f44ad49ca3a1479ca56043152518b9814237a23..983e957481b60deee8b79ac0fe9c7a4837fe68b1 100644
--- a/chrome/test/chromedriver/chrome/chrome_desktop_impl.cc
+++ b/chrome/test/chromedriver/chrome/chrome_desktop_impl.cc
@@ -4,6 +4,7 @@
#include "chrome/test/chromedriver/chrome/chrome_desktop_impl.h"
+#include "base/bind.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/posix/eintr_wrapper.h"
@@ -59,6 +60,13 @@ bool KillProcess(const base::Process& process, bool kill_gracefully) {
return true;
}
+void GetWebViewIdForAppWindow(const std::string& url_prefix,
+ std::string* web_view_id,
+ const WebViewInfo& view) {
+ if (view.type == WebViewInfo::kApp && view.url.find(url_prefix) == 0)
+ *web_view_id = view.id;
+}
+
} // namespace
ChromeDesktopImpl::ChromeDesktopImpl(
@@ -185,3 +193,25 @@ Status ChromeDesktopImpl::QuitImpl() {
const base::CommandLine& ChromeDesktopImpl::command() const {
return command_;
}
+
+Status ChromeDesktopImpl::WaitForNewAppWindow(const std::string& extension_id,
+ std::string* web_view_id,
+ const base::TimeDelta& timeout) {
+ base::TimeTicks deadline = base::TimeTicks::Now() + timeout;
+ std::string url_prefix = "chrome-extension://" + extension_id;
+ std::string web_view_id_tmp;
+ std::list<std::string> web_view_ids;
+ WebViewCallback callback =
+ base::Bind(&GetWebViewIdForAppWindow, url_prefix, &web_view_id_tmp);
+ while (base::TimeTicks::Now() < deadline) {
+ Status status = UpdateWebViewIds(&web_view_ids, callback);
+ if (status.IsError())
+ return status;
+ if (!web_view_id_tmp.empty()) {
+ *web_view_id = web_view_id_tmp;
+ return Status(kOk);
+ }
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(50));
+ }
+ return Status(kUnknownError, "timed out waiting for app window to appear");
+}

Powered by Google App Engine
This is Rietveld 408576698