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

Side by Side Diff: ash/login/ui/login_test_base.cc

Issue 2896533002: cros: Simple password view for lock. Adds test support. (Closed)
Patch Set: Initial upload 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ash/login/ui/login_test_base.h"
6
7 #include "components/user_manager/fake_user_manager.h"
8 #include "ui/views/widget/widget.h"
9 #include "ui/views/widget/widget_delegate.h"
10
11 namespace ash {
12
13 // A WidgetDelegate which ensures that |initially_focused| gets focus.
14 class LoginTestBase::WidgetDelegate : public views::WidgetDelegate {
15 public:
16 WidgetDelegate(views::View* initially_focused)
17 : initially_focused_(initially_focused) {}
18 ~WidgetDelegate() override = default;
19
20 // views::WidgetDelegate:
21 views::View* GetInitiallyFocusedView() override { return initially_focused_; }
22 views::Widget* GetWidget() override {
23 return initially_focused_->GetWidget();
24 }
25 const views::Widget* GetWidget() const override {
26 return initially_focused_->GetWidget();
27 }
28
29 private:
30 views::View* initially_focused_;
xiyuan 2017/05/24 20:11:02 nit: IMHO, it is easier to read if this is called
jdufault 2017/06/07 18:09:14 Done.
31
32 DISALLOW_COPY_AND_ASSIGN(WidgetDelegate);
33 };
34
35 LoginTestBase::LoginTestBase() {}
36
37 LoginTestBase::~LoginTestBase() {}
38
39 void LoginTestBase::ShowWidgetWithContent(views::View* content) {
40 EXPECT_FALSE(widget_) << "CreateWidget can only be called once.";
41
42 delegate_ = base::MakeUnique<WidgetDelegate>(content);
43
44 views::Widget::InitParams params(
45 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
46 params.context = CurrentContext();
47 params.bounds = gfx::Rect(0, 0, 800, 800);
48 params.delegate = delegate_.get();
49 widget_ = new views::Widget();
50 widget_->Init(params);
51 widget_->SetContentsView(content);
52 widget_->Show();
53 }
54
55 void LoginTestBase::SetUp() {
56 AshTestBase::SetUp();
57 fake_user_manager_ = base::MakeUnique<user_manager::FakeUserManager>();
xiyuan 2017/05/24 20:11:02 I don't think we will have a UserManager running i
jdufault 2017/06/07 18:09:14 Done.
58 }
59
60 void LoginTestBase::TearDown() {
61 if (widget_) {
62 widget_->Close();
63 widget_ = nullptr;
64 }
65
66 test::AshTestBase::TearDown();
67 }
68
69 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698