| Index: chrome/browser/extensions/api/tabs/tabs_test.cc
|
| diff --git a/chrome/browser/extensions/api/tabs/tabs_test.cc b/chrome/browser/extensions/api/tabs/tabs_test.cc
|
| index b42eb047ee8c0322e8150c2afb0210453809459e..5df6a2a4c3b67e3c163fe0b41fa560a98ec4148d 100644
|
| --- a/chrome/browser/extensions/api/tabs/tabs_test.cc
|
| +++ b/chrome/browser/extensions/api/tabs/tabs_test.cc
|
| @@ -9,6 +9,7 @@
|
| #include <memory>
|
| #include <string>
|
|
|
| +#include "apps/test/app_window_waiter.h"
|
| #include "base/memory/ref_counted.h"
|
| #include "base/strings/pattern.h"
|
| #include "base/strings/string_split.h"
|
| @@ -45,7 +46,6 @@
|
| #include "extensions/browser/api_test_utils.h"
|
| #include "extensions/browser/app_window/app_window.h"
|
| #include "extensions/browser/app_window/app_window_registry.h"
|
| -#include "extensions/browser/app_window/native_app_window.h"
|
| #include "extensions/common/manifest_constants.h"
|
| #include "extensions/common/test_util.h"
|
| #include "extensions/test/extension_test_message_listener.h"
|
| @@ -798,13 +798,13 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, UpdateDevToolsWindow) {
|
| // TODO(llandwerlin): Activating a browser window and waiting for the
|
| // action to happen requires views::Widget which is not available on
|
| // MacOSX. Deactivate for now.
|
| +// TODO(warx): Move ExtensionWindowLastFocusedTest to interactive
|
| +// uitest as it triggers native widget activation.
|
| #if !defined(OS_MACOSX)
|
| class ExtensionWindowLastFocusedTest : public ExtensionTabsTest {
|
| public:
|
| void SetUpOnMainThread() override;
|
|
|
| - void ActivateAppWindow(AppWindow* app_window);
|
| -
|
| void ActivateBrowserWindow(Browser* browser);
|
|
|
| Browser* CreateBrowserWithEmptyTab(bool as_popup);
|
| @@ -815,44 +815,6 @@ class ExtensionWindowLastFocusedTest : public ExtensionTabsTest {
|
| const std::string& params);
|
|
|
| private:
|
| - // A helper class to wait for an AppWindow to become activated. On
|
| - // window system like X11, for a NativeWidget to be activated, we
|
| - // need to wait for the round trip communication with the X server.
|
| - class AppWindowActivatedWaiter : public AppWindowRegistry::Observer {
|
| - public:
|
| - AppWindowActivatedWaiter(AppWindow* app_window,
|
| - content::BrowserContext* browser_context)
|
| - : app_window_(app_window),
|
| - browser_context_(browser_context),
|
| - waiting_(false) {
|
| - AppWindowRegistry::Get(browser_context_)->AddObserver(this);
|
| - }
|
| - ~AppWindowActivatedWaiter() override {
|
| - AppWindowRegistry::Get(browser_context_)->RemoveObserver(this);
|
| - }
|
| -
|
| - void ActivateAndWait() {
|
| - app_window_->GetBaseWindow()->Activate();
|
| - if (!app_window_->GetBaseWindow()->IsActive()) {
|
| - waiting_ = true;
|
| - content::RunMessageLoop();
|
| - }
|
| - }
|
| -
|
| - // AppWindowRegistry::Observer:
|
| - void OnAppWindowActivated(AppWindow* app_window) override {
|
| - if (app_window_ == app_window && waiting_) {
|
| - base::MessageLoopForUI::current()->QuitWhenIdle();
|
| - waiting_ = false;
|
| - }
|
| - }
|
| -
|
| - private:
|
| - AppWindow* app_window_;
|
| - content::BrowserContext* browser_context_;
|
| - bool waiting_;
|
| - };
|
| -
|
| // A helper class to wait for an views::Widget to become activated.
|
| class WidgetActivatedWaiter : public views::WidgetObserver {
|
| public:
|
| @@ -892,11 +854,6 @@ void ExtensionWindowLastFocusedTest::SetUpOnMainThread() {
|
| extension_ = test_util::CreateEmptyExtension();
|
| }
|
|
|
| -void ExtensionWindowLastFocusedTest::ActivateAppWindow(AppWindow* app_window) {
|
| - AppWindowActivatedWaiter waiter(app_window, browser()->profile());
|
| - waiter.ActivateAndWait();
|
| -}
|
| -
|
| void ExtensionWindowLastFocusedTest::ActivateBrowserWindow(Browser* browser) {
|
| BrowserView* view = BrowserView::GetBrowserViewForBrowser(browser);
|
| EXPECT_NE(nullptr, view);
|
| @@ -993,7 +950,9 @@ IN_PROC_BROWSER_TEST_F(ExtensionWindowLastFocusedTest,
|
| " \"minWidth\": 200, \"minHeight\": 200,"
|
| " \"maxWidth\": 400, \"maxHeight\": 400}}");
|
| {
|
| - ActivateAppWindow(app_window);
|
| + apps::AppWindowWaiter waiter(AppWindowRegistry::Get(browser()->profile()),
|
| + app_window->extension_id());
|
| + waiter.WaitForActivated();
|
|
|
| scoped_refptr<WindowsGetLastFocusedFunction> get_current_app_function =
|
| new WindowsGetLastFocusedFunction();
|
| @@ -1065,7 +1024,9 @@ IN_PROC_BROWSER_TEST_F(ExtensionWindowLastFocusedTest,
|
| " \"minWidth\": 200, \"minHeight\": 200,"
|
| " \"maxWidth\": 400, \"maxHeight\": 400}}");
|
| {
|
| - ActivateAppWindow(app_window);
|
| + apps::AppWindowWaiter waiter(AppWindowRegistry::Get(browser()->profile()),
|
| + app_window->extension_id());
|
| + waiter.WaitForActivated();
|
|
|
| scoped_refptr<WindowsGetLastFocusedFunction> get_current_app_function =
|
| new WindowsGetLastFocusedFunction();
|
|
|