Updates the mic icon status based on the device's audio state (2nd)
[chromium-blink-merge.git] / chrome / browser / chromeos / ui / idle_logout_dialog_view_browsertest.cc
blobf7433a5ef9b8a55738f07db3dad12338b56e94bf
1 // Copyright (c) 2012 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.
5 #include "chrome/browser/chromeos/ui/idle_logout_dialog_view.h"
7 #include "base/memory/scoped_ptr.h"
8 #include "chrome/browser/chromeos/kiosk_mode/mock_kiosk_mode_settings.h"
9 #include "chrome/test/base/in_process_browser_test.h"
10 #include "content/public/test/test_utils.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "ui/views/widget/widget.h"
14 namespace chromeos {
16 class MockIdleLogoutSettingsProvider : public IdleLogoutSettingsProvider {
17 public:
18 explicit MockIdleLogoutSettingsProvider(KioskModeSettings* mock_settings)
19 : mock_settings_(mock_settings) {}
21 virtual base::TimeDelta GetCountdownUpdateInterval() override {
22 return base::TimeDelta::FromMilliseconds(0);
25 virtual KioskModeSettings* GetKioskModeSettings() override {
26 return mock_settings_;
29 virtual void LogoutCurrentUser(IdleLogoutDialogView* dialog) override {
30 dialog->GetWidget()->Close();
33 private:
34 KioskModeSettings* mock_settings_;
36 DISALLOW_COPY_AND_ASSIGN(MockIdleLogoutSettingsProvider);
39 class IdleLogoutDialogViewTest : public InProcessBrowserTest {
40 public:
41 IdleLogoutDialogViewTest() {}
43 virtual ~IdleLogoutDialogViewTest() {}
45 virtual void SetUpOnMainThread() override {
46 mock_settings_.reset(new MockKioskModeSettings());
47 mock_provider_.reset(
48 new MockIdleLogoutSettingsProvider(mock_settings_.get()));
49 IdleLogoutDialogView::set_settings_provider(mock_provider_.get());
52 void ExpectOpenDialog() {
53 IdleLogoutDialogView* dialog = IdleLogoutDialogView::current_instance();
54 ASSERT_TRUE(dialog != NULL);
55 EXPECT_TRUE(dialog->visible());
58 void ExpectClosedDialog() {
59 EXPECT_TRUE(IdleLogoutDialogView::current_instance() == NULL);
62 private:
63 scoped_ptr<MockIdleLogoutSettingsProvider> mock_provider_;
64 scoped_ptr<MockKioskModeSettings> mock_settings_;
66 DISALLOW_COPY_AND_ASSIGN(IdleLogoutDialogViewTest);
69 IN_PROC_BROWSER_TEST_F(IdleLogoutDialogViewTest, ShowDialogAndClose) {
70 IdleLogoutDialogView::ShowDialog();
71 EXPECT_NO_FATAL_FAILURE(ExpectOpenDialog());
73 IdleLogoutDialogView::CloseDialog();
74 ExpectClosedDialog();
77 IN_PROC_BROWSER_TEST_F(IdleLogoutDialogViewTest, ShowDialogAndCloseView) {
78 IdleLogoutDialogView::ShowDialog();
79 EXPECT_NO_FATAL_FAILURE(ExpectOpenDialog());
81 IdleLogoutDialogView::CloseDialog();
82 content::RunAllPendingInMessageLoop();
83 ExpectClosedDialog();
86 IN_PROC_BROWSER_TEST_F(IdleLogoutDialogViewTest, ShowDialogAndCloseViewClose) {
87 IdleLogoutDialogView::ShowDialog();
88 EXPECT_NO_FATAL_FAILURE(ExpectOpenDialog());
90 IdleLogoutDialogView::CloseDialog();
91 content::RunAllPendingInMessageLoop();
92 IdleLogoutDialogView::CloseDialog();
94 ExpectClosedDialog();
97 IN_PROC_BROWSER_TEST_F(IdleLogoutDialogViewTest,
98 OutOfOrderMultipleShowDialogAndClose) {
99 IdleLogoutDialogView::CloseDialog();
100 ExpectClosedDialog();
102 IdleLogoutDialogView::ShowDialog();
103 EXPECT_NO_FATAL_FAILURE(ExpectOpenDialog());
104 IdleLogoutDialogView::ShowDialog();
105 EXPECT_NO_FATAL_FAILURE(ExpectOpenDialog());
107 IdleLogoutDialogView::CloseDialog();
108 ExpectClosedDialog();
109 IdleLogoutDialogView::CloseDialog();
110 ExpectClosedDialog();
113 IN_PROC_BROWSER_TEST_F(IdleLogoutDialogViewTest,
114 ShowDialogAndFinishCountdown) {
115 IdleLogoutDialogView::ShowDialog();
116 EXPECT_NO_FATAL_FAILURE(ExpectOpenDialog());
118 content::RunAllPendingInMessageLoop();
119 ExpectClosedDialog();
122 } // namespace chromeos