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

Unified Diff: ash/login/lock_screen_controller_unittest.cc

Issue 2876673002: mojo api for view based lockscreen (Closed)
Patch Set: Incorporate comments from patch set 8 and rebase 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 | « ash/login/lock_screen_controller.cc ('k') | ash/login/ui/lock_contents_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/login/lock_screen_controller_unittest.cc
diff --git a/ash/login/lock_screen_controller_unittest.cc b/ash/login/lock_screen_controller_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..cc3f8d45e43c2467b4a1d1703b27e42b957905d0
--- /dev/null
+++ b/ash/login/lock_screen_controller_unittest.cc
@@ -0,0 +1,61 @@
+// 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/lock_screen_controller.h"
+
+#include "ash/shell.h"
+#include "ash/test/ash_test_base.h"
+#include "base/run_loop.h"
+#include "chromeos/cryptohome/system_salt_getter.h"
+
+namespace ash {
+
+namespace {
+
+class TestLockScreenClient : public mojom::LockScreenClient {
+ public:
+ TestLockScreenClient() : binding_(this) {}
+ ~TestLockScreenClient() override = default;
+
+ mojom::LockScreenClientPtr CreateInterfacePtrAndBind() {
+ return binding_.CreateInterfacePtrAndBind();
+ }
+
+ // mojom::LockScreenClient:
+ void AuthenticateUser(const AccountId& account_id,
+ const std::string& password,
+ bool authenticated_by_pin) override {
+ ++autentication_requests_count_;
+ }
+
+ int authentication_requests_count() const {
+ return autentication_requests_count_;
+ }
+
+ private:
+ mojo::Binding<ash::mojom::LockScreenClient> binding_;
+ int autentication_requests_count_ = 0;
+
+ DISALLOW_COPY_AND_ASSIGN(TestLockScreenClient);
+};
+
+using LockScreenControllerTest = test::AshTestBase;
+
+} // namespace
+
+TEST_F(LockScreenControllerTest, RequestAuthentication) {
+ LockScreenController* lock_screen_controller =
+ Shell::Get()->lock_screen_controller();
+ TestLockScreenClient lock_screen_client;
+ lock_screen_controller->SetClient(
+ lock_screen_client.CreateInterfacePtrAndBind());
+ EXPECT_EQ(0, lock_screen_client.authentication_requests_count());
+
+ AccountId id = AccountId::FromUserEmail("user1@test.com");
+ lock_screen_controller->AuthenticateUser(id, std::string(), false);
+ base::RunLoop().RunUntilIdle();
+ EXPECT_EQ(1, lock_screen_client.authentication_requests_count());
+}
+
+} // namespace ash
« no previous file with comments | « ash/login/lock_screen_controller.cc ('k') | ash/login/ui/lock_contents_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698