Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/views/test/widget_test.h" | 5 #include "ui/views/test/widget_test.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "ui/gfx/native_widget_types.h" | 8 #include "ui/gfx/native_widget_types.h" |
| 9 #include "ui/views/test/native_widget_factory.h" | 9 #include "ui/views/test/native_widget_factory.h" |
| 10 #include "ui/views/widget/root_view.h" | 10 #include "ui/views/widget/root_view.h" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 GetWidget()->Init(params); | 143 GetWidget()->Init(params); |
| 144 GetWidget()->GetContentsView()->AddChildView(view_); | 144 GetWidget()->GetContentsView()->AddChildView(view_); |
| 145 } | 145 } |
| 146 | 146 |
| 147 TestInitialFocusWidgetDelegate::~TestInitialFocusWidgetDelegate() {} | 147 TestInitialFocusWidgetDelegate::~TestInitialFocusWidgetDelegate() {} |
| 148 | 148 |
| 149 View* TestInitialFocusWidgetDelegate::GetInitiallyFocusedView() { | 149 View* TestInitialFocusWidgetDelegate::GetInitiallyFocusedView() { |
| 150 return view_; | 150 return view_; |
| 151 } | 151 } |
| 152 | 152 |
| 153 WidgetActivationWaiter::WidgetActivationWaiter(Widget* widget, bool active) | |
| 154 : observed_(false), active_(active) { | |
| 155 if (active == widget->IsActive()) { | |
| 156 observed_ = true; | |
| 157 return; | |
| 158 } | |
| 159 EXPECT_NE(active, widget->IsActive()); | |
|
sky
2016/10/12 19:23:53
There is no point in this call now.
Qiang(Joe) Xu
2016/10/12 20:25:16
Done.
| |
| 160 widget->AddObserver(this); | |
| 161 } | |
| 162 | |
| 163 WidgetActivationWaiter::~WidgetActivationWaiter() {} | |
| 164 | |
| 165 void WidgetActivationWaiter::Wait() { | |
| 166 if (!observed_) | |
| 167 run_loop_.Run(); | |
| 168 } | |
| 169 | |
| 170 void WidgetActivationWaiter::OnWidgetActivationChanged(Widget* widget, | |
| 171 bool active) { | |
| 172 if (active_ != active) | |
| 173 return; | |
| 174 | |
| 175 observed_ = true; | |
| 176 widget->RemoveObserver(this); | |
| 177 if (run_loop_.running()) | |
| 178 run_loop_.Quit(); | |
| 179 } | |
| 180 | |
| 153 } // namespace test | 181 } // namespace test |
| 154 } // namespace views | 182 } // namespace views |
| OLD | NEW |