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

Unified Diff: chrome/browser/chromeos/ui/password_echo_controller_browsertest.cc

Issue 2279163002: cros: Bind password echo with TouchView mode
Patch Set: do not run for mash to fix mash test Created 4 years, 4 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
Index: chrome/browser/chromeos/ui/password_echo_controller_browsertest.cc
diff --git a/chrome/browser/chromeos/ui/password_echo_controller_browsertest.cc b/chrome/browser/chromeos/ui/password_echo_controller_browsertest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f55a394b37a705eec85bceecb769a9476be27356
--- /dev/null
+++ b/chrome/browser/chromeos/ui/password_echo_controller_browsertest.cc
@@ -0,0 +1,156 @@
+// Copyright 2016 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 "chrome/browser/chromeos/ui/password_echo_controller.h"
+
+#include <memory>
+
+#include "ash/common/ash_switches.h"
+#include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
+#include "ash/common/wm_shell.h"
+#include "base/command_line.h"
+#include "base/macros.h"
+#include "chrome/browser/ui/ash/ash_util.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "chrome/test/base/in_process_browser_test.h"
+#include "chrome/test/base/ui_test_utils.cc"
+#include "content/public/browser/render_view_host.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/common/web_preferences.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/views/controls/textfield/textfield.h"
+#include "ui/views/views_delegate.h"
+
+namespace chromeos {
+
+class PasswordEchoControllerTest : public InProcessBrowserTest {
+ public:
+ PasswordEchoControllerTest() {}
+ ~PasswordEchoControllerTest() override {}
+
+ // InProcessBrowserTest
+ void SetUpCommandLine(base::CommandLine* command_line) override {
+ command_line->AppendSwitch(ash::switches::kAshEnableTouchViewTesting);
+ }
+
+ content::WebPreferences GetWebPreferences() {
+ return browser()
+ ->tab_strip_model()
+ ->GetActiveWebContents()
+ ->GetRenderViewHost()
+ ->GetWebkitPreferences();
+ }
+
+ ash::MaximizeModeController* GetMaximizeModeController() {
+ return ash::WmShell::Get()->maximize_mode_controller();
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(PasswordEchoControllerTest);
+};
+
+IN_PROC_BROWSER_TEST_F(PasswordEchoControllerTest, ExistingWebContents) {
+ if (chrome::IsRunningInMash())
+ return;
+
+ ash::MaximizeModeController* const controller = GetMaximizeModeController();
+
+ // No TouchView mode at the beginning.
+ ASSERT_FALSE(controller->IsMaximizeModeWindowManagerEnabled());
+ EXPECT_FALSE(GetWebPreferences().password_echo_enabled);
+
+ // Enter TouchView mode and password echo should be enabled.
+ controller->EnableMaximizeModeWindowManager(true);
+ ASSERT_TRUE(controller->IsMaximizeModeWindowManagerEnabled());
+ EXPECT_TRUE(GetWebPreferences().password_echo_enabled);
+
+ // Leave TouchView mode and password echo should be enabled.
+ controller->EnableMaximizeModeWindowManager(false);
+ ASSERT_FALSE(controller->IsMaximizeModeWindowManagerEnabled());
+ EXPECT_FALSE(GetWebPreferences().password_echo_enabled);
+}
+
+IN_PROC_BROWSER_TEST_F(PasswordEchoControllerTest, NewWebContents) {
+ if (chrome::IsRunningInMash())
+ return;
+
+ ash::MaximizeModeController* const controller = GetMaximizeModeController();
+
+ // No TouchView mode at the beginning.
+ ASSERT_FALSE(controller->IsMaximizeModeWindowManagerEnabled());
+ EXPECT_FALSE(GetWebPreferences().password_echo_enabled);
+
+ // Enter TouchView mode and password echo should be enabled.
+ controller->EnableMaximizeModeWindowManager(true);
+ ASSERT_TRUE(controller->IsMaximizeModeWindowManagerEnabled());
+
+ const GURL url("about:blank");
+ ui_test_utils::NavigateToURLWithDisposition(browser(), url,
+ NEW_FOREGROUND_TAB, 0);
+ EXPECT_TRUE(GetWebPreferences().password_echo_enabled);
+
+ // Leave TouchView mode and password echo should be enabled.
+ controller->EnableMaximizeModeWindowManager(false);
+ ASSERT_FALSE(controller->IsMaximizeModeWindowManagerEnabled());
+
+ ui_test_utils::NavigateToURLWithDisposition(browser(), url,
+ NEW_FOREGROUND_TAB, 0);
+ EXPECT_FALSE(GetWebPreferences().password_echo_enabled);
+}
+
+IN_PROC_BROWSER_TEST_F(PasswordEchoControllerTest, ExistingTextfield) {
+ if (chrome::IsRunningInMash())
+ return;
+
+ ash::MaximizeModeController* const controller = GetMaximizeModeController();
+ views::ViewsDelegate* const views_delegate =
+ views::ViewsDelegate::GetInstance();
+
+ std::unique_ptr<views::Textfield> textfield(new views::Textfield);
+
+ // No TouchView mode at the beginning.
+ ASSERT_FALSE(controller->IsMaximizeModeWindowManagerEnabled());
+ EXPECT_TRUE(views_delegate->GetTextfieldPasswordRevealDuration().is_zero());
+
+ // Enter TouchView mode and password echo should be enabled.
+ controller->EnableMaximizeModeWindowManager(true);
+ ASSERT_TRUE(controller->IsMaximizeModeWindowManagerEnabled());
+ EXPECT_FALSE(views_delegate->GetTextfieldPasswordRevealDuration().is_zero());
+
+ // Leave TouchView mode and password echo should be enabled.
+ controller->EnableMaximizeModeWindowManager(false);
+ ASSERT_FALSE(controller->IsMaximizeModeWindowManagerEnabled());
+ EXPECT_TRUE(views_delegate->GetTextfieldPasswordRevealDuration().is_zero());
+}
+
+IN_PROC_BROWSER_TEST_F(PasswordEchoControllerTest, NewTextfield) {
+ if (chrome::IsRunningInMash())
+ return;
+
+ ash::MaximizeModeController* const controller = GetMaximizeModeController();
+ views::ViewsDelegate* const views_delegate =
+ views::ViewsDelegate::GetInstance();
+
+ std::unique_ptr<views::Textfield> textfield;
+
+ // No TouchView mode at the beginning.
+ ASSERT_FALSE(controller->IsMaximizeModeWindowManagerEnabled());
+ textfield.reset(new views::Textfield);
+ EXPECT_TRUE(views_delegate->GetTextfieldPasswordRevealDuration().is_zero());
+
+ // Enter TouchView mode and password echo should be enabled.
+ controller->EnableMaximizeModeWindowManager(true);
+ ASSERT_TRUE(controller->IsMaximizeModeWindowManagerEnabled());
+ textfield.reset(new views::Textfield);
+ EXPECT_FALSE(views_delegate->GetTextfieldPasswordRevealDuration().is_zero());
+
+ // Leave TouchView mode and password echo should be enabled.
+ controller->EnableMaximizeModeWindowManager(false);
+ ASSERT_FALSE(controller->IsMaximizeModeWindowManagerEnabled());
+ textfield.reset(new views::Textfield);
+ EXPECT_TRUE(views_delegate->GetTextfieldPasswordRevealDuration().is_zero());
+}
+
+} // namespace chromeos
« no previous file with comments | « chrome/browser/chromeos/ui/password_echo_controller.cc ('k') | chrome/browser/ui/views/chrome_views_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698