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

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: Address comments Created 3 years, 6 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
« no previous file with comments | « ash/login/ui/login_test_base.h ('k') | ash/system/tray/size_range_layout.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ui/views/widget/widget.h"
8 #include "ui/views/widget/widget_delegate.h"
9
10 namespace ash {
11
12 // A WidgetDelegate which ensures that |initially_focused| gets focus.
13 class LoginTestBase::WidgetDelegate : public views::WidgetDelegate {
14 public:
15 WidgetDelegate(views::View* content) : content_(content) {}
16 ~WidgetDelegate() override = default;
17
18 // views::WidgetDelegate:
19 views::View* GetInitiallyFocusedView() override { return content_; }
20 views::Widget* GetWidget() override { return content_->GetWidget(); }
21 const views::Widget* GetWidget() const override {
22 return content_->GetWidget();
23 }
24
25 private:
26 views::View* content_;
27
28 DISALLOW_COPY_AND_ASSIGN(WidgetDelegate);
29 };
30
31 LoginTestBase::LoginTestBase() {}
32
33 LoginTestBase::~LoginTestBase() {}
34
35 void LoginTestBase::ShowWidgetWithContent(views::View* content) {
36 EXPECT_FALSE(widget_) << "CreateWidget can only be called once.";
37
38 delegate_ = base::MakeUnique<WidgetDelegate>(content);
39
40 views::Widget::InitParams params(
41 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
42 params.context = CurrentContext();
43 params.bounds = gfx::Rect(0, 0, 800, 800);
44 params.delegate = delegate_.get();
45 widget_ = new views::Widget();
46 widget_->Init(params);
47 widget_->SetContentsView(content);
48 widget_->Show();
49 }
50
51 void LoginTestBase::TearDown() {
52 if (widget_) {
53 widget_->Close();
54 widget_ = nullptr;
55 }
56
57 test::AshTestBase::TearDown();
58 }
59
60 } // namespace ash
OLDNEW
« no previous file with comments | « ash/login/ui/login_test_base.h ('k') | ash/system/tray/size_range_layout.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698