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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/login/ui/login_test_base.cc
diff --git a/ash/login/ui/login_test_base.cc b/ash/login/ui/login_test_base.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1c9d822b6a9a1aec4081c17228c2d49df64c04c1
--- /dev/null
+++ b/ash/login/ui/login_test_base.cc
@@ -0,0 +1,60 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/login/ui/login_test_base.h"
+
+#include "ui/views/widget/widget.h"
+#include "ui/views/widget/widget_delegate.h"
+
+namespace ash {
+
+// A WidgetDelegate which ensures that |initially_focused| gets focus.
+class LoginTestBase::WidgetDelegate : public views::WidgetDelegate {
+ public:
+ WidgetDelegate(views::View* content) : content_(content) {}
+ ~WidgetDelegate() override = default;
+
+ // views::WidgetDelegate:
+ views::View* GetInitiallyFocusedView() override { return content_; }
+ views::Widget* GetWidget() override { return content_->GetWidget(); }
+ const views::Widget* GetWidget() const override {
+ return content_->GetWidget();
+ }
+
+ private:
+ views::View* content_;
+
+ DISALLOW_COPY_AND_ASSIGN(WidgetDelegate);
+};
+
+LoginTestBase::LoginTestBase() {}
+
+LoginTestBase::~LoginTestBase() {}
+
+void LoginTestBase::ShowWidgetWithContent(views::View* content) {
+ EXPECT_FALSE(widget_) << "CreateWidget can only be called once.";
+
+ delegate_ = base::MakeUnique<WidgetDelegate>(content);
+
+ views::Widget::InitParams params(
+ views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
+ params.context = CurrentContext();
+ params.bounds = gfx::Rect(0, 0, 800, 800);
+ params.delegate = delegate_.get();
+ widget_ = new views::Widget();
+ widget_->Init(params);
+ widget_->SetContentsView(content);
+ widget_->Show();
+}
+
+void LoginTestBase::TearDown() {
+ if (widget_) {
+ widget_->Close();
+ widget_ = nullptr;
+ }
+
+ test::AshTestBase::TearDown();
+}
+
+} // namespace ash
« 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