OLD | NEW |
(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 <memory> |
| 6 #include <utility> |
| 7 |
| 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/run_loop.h" |
| 10 #include "chrome/browser/chromeos/login/login_manager_test.h" |
| 11 #include "chrome/browser/chromeos/login/startup_utils.h" |
| 12 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h" |
| 13 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
| 14 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" |
| 15 #include "chromeos/dbus/dbus_thread_manager.h" |
| 16 #include "chromeos/dbus/fake_cryptohome_client.h" |
| 17 |
| 18 namespace chromeos { |
| 19 |
| 20 namespace { |
| 21 |
| 22 constexpr char kTestUser1[] = "test-user1@gmail.com"; |
| 23 constexpr char kTestUser2[] = "test-user2@gmail.com"; |
| 24 |
| 25 } // namespace |
| 26 |
| 27 class UserSelectionScreenTest : public LoginManagerTest { |
| 28 public: |
| 29 UserSelectionScreenTest() |
| 30 : LoginManagerTest(false /* should_launch_browser */) {} |
| 31 ~UserSelectionScreenTest() override = default; |
| 32 |
| 33 // LoginManagerTest: |
| 34 void SetUpInProcessBrowserTestFixture() override { |
| 35 auto cryptohome_client = base::MakeUnique<chromeos::FakeCryptohomeClient>(); |
| 36 fake_cryptohome_client_ = cryptohome_client.get(); |
| 37 DBusThreadManager::GetSetterForTesting()->SetCryptohomeClient( |
| 38 std::move(cryptohome_client)); |
| 39 } |
| 40 |
| 41 FakeCryptohomeClient* fake_cryptohome_client() { |
| 42 return fake_cryptohome_client_; |
| 43 } |
| 44 |
| 45 OobeUI* GetOobeUI() { |
| 46 return static_cast<OobeUI*>(web_contents()->GetWebUI()->GetController()); |
| 47 } |
| 48 |
| 49 private: |
| 50 // DBusThreadManager owns this. |
| 51 FakeCryptohomeClient* fake_cryptohome_client_ = nullptr; |
| 52 |
| 53 DISALLOW_COPY_AND_ASSIGN(UserSelectionScreenTest); |
| 54 }; |
| 55 |
| 56 IN_PROC_BROWSER_TEST_F(UserSelectionScreenTest, |
| 57 PRE_ShowDircryptoMigrationBanner) { |
| 58 RegisterUser(kTestUser1); |
| 59 RegisterUser(kTestUser2); |
| 60 StartupUtils::MarkOobeCompleted(); |
| 61 } |
| 62 |
| 63 // Test that a banner shows up for users that need dircrypto migration. |
| 64 IN_PROC_BROWSER_TEST_F(UserSelectionScreenTest, ShowDircryptoMigrationBanner) { |
| 65 // No banner for the first user since default is no migration. |
| 66 JSExpect("!$('signin-banner').classList.contains('message-set')"); |
| 67 |
| 68 // Change the needs dircrypto migration response. |
| 69 fake_cryptohome_client()->set_needs_dircrypto_migration(true); |
| 70 |
| 71 // Focus to the 2nd user pod. |
| 72 base::RunLoop pod_focus_wait_loop; |
| 73 GetOobeUI()->signin_screen_handler()->SetFocusPODCallbackForTesting( |
| 74 pod_focus_wait_loop.QuitClosure()); |
| 75 js_checker().Evaluate("$('pod-row').focusPod($('pod-row').pods[1])"); |
| 76 pod_focus_wait_loop.Run(); |
| 77 |
| 78 // Wait for FakeCryptohomeClient to send back the check result. |
| 79 base::RunLoop().RunUntilIdle(); |
| 80 |
| 81 // Banner should be shown for the 2nd user. |
| 82 JSExpect("$('signin-banner').classList.contains('message-set')"); |
| 83 } |
| 84 |
| 85 } // namespace chromeos |
OLD | NEW |