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

Unified Diff: chrome/browser/ui/views/frame/browser_view_focus_uitest.cc

Issue 1233913009: Make File-Picker modal on Linux (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: close the file-picker when the test is done. Created 5 years, 3 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/browser/ui/views/frame/browser_view_focus_uitest.cc
diff --git a/chrome/browser/ui/views/frame/browser_view_focus_uitest.cc b/chrome/browser/ui/views/frame/browser_view_focus_uitest.cc
index 3d0aaf888fd2ff89b2c129f0fc9f9053fbfa294b..d6d07e09c526afc1dee69e3bdd6dfa6236fe418d 100644
--- a/chrome/browser/ui/views/frame/browser_view_focus_uitest.cc
+++ b/chrome/browser/ui/views/frame/browser_view_focus_uitest.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/ui/views/frame/browser_view.h"
+#include "base/run_loop.h"
#include "build/build_config.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
@@ -16,6 +17,8 @@
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "ui/views/focus/focus_manager.h"
#include "ui/views/view.h"
+#include "ui/views/widget/widget.h"
+#include "ui/views/widget/widget_observer.h"
#include "url/gurl.h"
const char kSimplePage[] = "/focus/page_with_focus.html";
@@ -27,6 +30,34 @@ class BrowserViewFocusTest : public InProcessBrowserTest {
}
};
+// Spins a run loop until a Widget becomes inactive.
+class WidgetActivationWaiter : public views::WidgetObserver {
+ public:
+ explicit WidgetActivationWaiter(views::Widget* widget) : observed_(false) {
+ widget->AddObserver(this);
+ EXPECT_TRUE(widget->IsActive());
+ }
+
+ void Wait() {
+ if (!observed_)
+ run_loop_.Run();
+ }
+
+ void OnWidgetActivationChanged(views::Widget* widget, bool active) override {
+ EXPECT_FALSE(active);
+ observed_ = true;
+ widget->RemoveObserver(this);
+ if (run_loop_.running())
+ run_loop_.Quit();
+ }
+
+ private:
+ base::RunLoop run_loop_;
+ bool observed_;
+
+ DISALLOW_COPY_AND_ASSIGN(WidgetActivationWaiter);
+};
+
// Flaky, http://crbug.com/69034.
IN_PROC_BROWSER_TEST_F(BrowserViewFocusTest, DISABLED_BrowsersRememberFocus) {
ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
@@ -93,3 +124,48 @@ IN_PROC_BROWSER_TEST_F(BrowserViewFocusTest, DISABLED_BrowsersRememberFocus) {
browser_view2->Close();
#endif
}
+
+// This test is only for Linux Desktop.
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+#define MAYBE_BrowserDialogModalTest BrowserDialogModalTest
+#else
+#define MAYBE_BrowserDialogModalTest DISABLED_BrowserDialogModalTest
+#endif
+IN_PROC_BROWSER_TEST_F(BrowserViewFocusTest, MAYBE_BrowserDialogModalTest) {
+ ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
+ ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
+
+ const GURL url = embedded_test_server()->GetURL(kSimplePage);
+ ui_test_utils::NavigateToURL(browser(), url);
+ ASSERT_TRUE(browser()->window()->IsActive());
+
+ browser()->OpenFile();
+
+ gfx::NativeWindow window = browser()->window()->GetNativeWindow();
+ views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window);
+ ASSERT_NE(nullptr, widget);
+
+ // Run a nested loop until the browser window becomes inactive.
+ WidgetActivationWaiter waiter(widget);
+ waiter.Wait();
+ EXPECT_FALSE(browser()->window()->IsActive());
+
+ ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER);
+ // The window should not get focus due to modal dialog.
+ EXPECT_FALSE(browser()->window()->IsActive());
+
+ ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
+ EXPECT_FALSE(browser()->window()->IsActive());
+
+ ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(window));
+ EXPECT_FALSE(browser()->window()->IsActive());
+
+ ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
+ browser(), ui::VKEY_TAB, false, false, true, false));
+ EXPECT_FALSE(browser()->window()->IsActive());
+
+ browser()->CloseFileDialog();
+
+ ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER);
+ EXPECT_TRUE(browser()->window()->IsActive());
+}

Powered by Google App Engine
This is Rietveld 408576698