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

Unified Diff: ui/views/widget/widget_interactive_uitest.cc

Issue 2891893002: Fix Restore after Minimize on X11. (Closed)
Patch Set: Fix review comments Created 3 years, 7 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
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/widget/widget_interactive_uitest.cc
diff --git a/ui/views/widget/widget_interactive_uitest.cc b/ui/views/widget/widget_interactive_uitest.cc
index a2f699d45992fbaf15338c7e02252a414e3c3b54..d22f156465c1ab1a4a8579f8c6e3e7fb1cb0f088 100644
--- a/ui/views/widget/widget_interactive_uitest.cc
+++ b/ui/views/widget/widget_interactive_uitest.cc
@@ -231,6 +231,43 @@ void ShowInactiveSync(Widget* widget) {
RunPendingMessagesForActiveStatusChange();
}
+// Wait until |callback| returns |expected_value|, but no longer than 1 second.
+class PropertyWaiter {
+ public:
+ PropertyWaiter(const base::Callback<bool(void)>& callback,
+ bool expected_value)
+ : callback_(callback), expected_value_(expected_value) {}
+
+ bool Wait() {
+ if (callback_.Run() == expected_value_) {
+ success_ = true;
+ return success_;
+ }
+ start_time_ = base::TimeTicks::Now();
+ timer_.Start(FROM_HERE, base::TimeDelta(), this, &PropertyWaiter::Check);
+ run_loop_.Run();
+ return success_;
+ }
+
+ private:
+ void Check() {
+ DCHECK(!success_);
+ success_ = callback_.Run() == expected_value_;
+ if (success_ || base::TimeTicks::Now() - start_time_ > kTimeout) {
+ timer_.Stop();
+ run_loop_.Quit();
+ }
+ }
+
+ const base::TimeDelta kTimeout = base::TimeDelta::FromSeconds(1);
+ base::Callback<bool(void)> callback_;
+ const bool expected_value_;
+ bool success_ = false;
+ base::TimeTicks start_time_;
+ base::RunLoop run_loop_;
+ base::RepeatingTimer timer_;
+};
+
} // namespace
class WidgetTestInteractive : public WidgetTest {
@@ -1215,6 +1252,24 @@ TEST_F(WidgetTestInteractive, InitialFocus) {
EXPECT_EQ(delegate.view(), widget->GetFocusManager()->GetStoredFocusView());
}
+TEST_F(WidgetTestInteractive, RestoreAfterMinimize) {
+ Widget* widget = CreateWidget();
+ ShowSync(widget);
+ ASSERT_FALSE(widget->IsMinimized());
+
+ PropertyWaiter minimize_waiter(
+ base::Bind(&Widget::IsMinimized, base::Unretained(widget)), true);
+ widget->Minimize();
+ EXPECT_TRUE(minimize_waiter.Wait());
+
+ PropertyWaiter restore_waiter(
+ base::Bind(&Widget::IsMinimized, base::Unretained(widget)), false);
+ widget->Restore();
+ EXPECT_TRUE(restore_waiter.Wait());
+
+ widget->CloseNow();
+}
+
namespace {
// Helper class for CaptureLostTrackingWidget to store whether
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698