OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
7 #include "chrome/browser/password_manager/chrome_password_manager_client.h" | 7 #include "chrome/browser/password_manager/chrome_password_manager_client.h" |
8 #include "chrome/browser/password_manager/password_manager_test_base.h" | 8 #include "chrome/browser/password_manager/password_manager_test_base.h" |
9 #include "chrome/browser/password_manager/password_store_factory.h" | 9 #include "chrome/browser/password_manager/password_store_factory.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/browser/ui/autofill/password_generation_popup_observer.h" | 11 #include "chrome/browser/ui/autofill/password_generation_popup_observer.h" |
12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 13 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
14 #include "chrome/test/base/in_process_browser_test.h" | 14 #include "chrome/test/base/in_process_browser_test.h" |
15 #include "chrome/test/base/ui_test_utils.h" | 15 #include "chrome/test/base/ui_test_utils.h" |
16 #include "components/autofill/core/browser/autofill_test_utils.h" | 16 #include "components/autofill/core/browser/autofill_test_utils.h" |
17 #include "components/autofill/core/common/autofill_switches.h" | 17 #include "components/autofill/core/common/autofill_switches.h" |
18 #include "components/password_manager/core/browser/password_generation_manager.h
" | 18 #include "components/password_manager/core/browser/password_generation_manager.h
" |
19 #include "components/password_manager/core/browser/test_password_store.h" | 19 #include "components/password_manager/core/browser/test_password_store.h" |
20 #include "content/public/browser/render_view_host.h" | 20 #include "content/public/browser/render_view_host.h" |
21 #include "content/public/browser/render_widget_host.h" | 21 #include "content/public/browser/render_widget_host.h" |
22 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
23 #include "content/public/test/browser_test_utils.h" | 23 #include "content/public/test/browser_test_utils.h" |
24 #include "net/test/embedded_test_server/embedded_test_server.h" | 24 #include "net/test/embedded_test_server/embedded_test_server.h" |
25 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
| 26 #include "ui/events/base_event_utils.h" |
26 #include "ui/events/keycodes/keyboard_codes.h" | 27 #include "ui/events/keycodes/keyboard_codes.h" |
27 | 28 |
28 namespace { | 29 namespace { |
29 | 30 |
30 class TestPopupObserver : public autofill::PasswordGenerationPopupObserver { | 31 class TestPopupObserver : public autofill::PasswordGenerationPopupObserver { |
31 public: | 32 public: |
32 TestPopupObserver() | 33 TestPopupObserver() |
33 : popup_showing_(false), | 34 : popup_showing_(false), |
34 password_visible_(false) {} | 35 password_visible_(false) {} |
35 virtual ~TestPopupObserver() {} | 36 virtual ~TestPopupObserver() {} |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 return focused_element; | 110 return focused_element; |
110 } | 111 } |
111 | 112 |
112 void FocusPasswordField() { | 113 void FocusPasswordField() { |
113 ASSERT_TRUE(content::ExecuteScript( | 114 ASSERT_TRUE(content::ExecuteScript( |
114 RenderViewHost(), | 115 RenderViewHost(), |
115 "document.getElementById('password_field').focus()")); | 116 "document.getElementById('password_field').focus()")); |
116 } | 117 } |
117 | 118 |
118 void SendKeyToPopup(ui::KeyboardCode key) { | 119 void SendKeyToPopup(ui::KeyboardCode key) { |
119 content::NativeWebKeyboardEvent event; | 120 content::NativeWebKeyboardEvent event( |
| 121 blink::WebKeyboardEvent::RawKeyDown, blink::WebInputEvent::NoModifiers, |
| 122 blink::WebInputEvent::TimeStampForTesting); |
120 event.windowsKeyCode = key; | 123 event.windowsKeyCode = key; |
121 event.type = blink::WebKeyboardEvent::RawKeyDown; | |
122 RenderViewHost()->GetWidget()->ForwardKeyboardEvent(event); | 124 RenderViewHost()->GetWidget()->ForwardKeyboardEvent(event); |
123 } | 125 } |
124 | 126 |
125 bool GenerationPopupShowing() { | 127 bool GenerationPopupShowing() { |
126 return observer_.popup_showing() && observer_.password_visible(); | 128 return observer_.popup_showing() && observer_.password_visible(); |
127 } | 129 } |
128 | 130 |
129 bool EditingPopupShowing() { | 131 bool EditingPopupShowing() { |
130 return observer_.popup_showing() && !observer_.password_visible(); | 132 return observer_.popup_showing() && !observer_.password_visible(); |
131 } | 133 } |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 EXPECT_FALSE(password_store->IsEmpty()); | 222 EXPECT_FALSE(password_store->IsEmpty()); |
221 | 223 |
222 // Make sure the username is correct. | 224 // Make sure the username is correct. |
223 password_manager::TestPasswordStore::PasswordMap stored_passwords = | 225 password_manager::TestPasswordStore::PasswordMap stored_passwords = |
224 password_store->stored_passwords(); | 226 password_store->stored_passwords(); |
225 EXPECT_EQ(1u, stored_passwords.size()); | 227 EXPECT_EQ(1u, stored_passwords.size()); |
226 EXPECT_EQ(1u, stored_passwords.begin()->second.size()); | 228 EXPECT_EQ(1u, stored_passwords.begin()->second.size()); |
227 EXPECT_EQ(base::UTF8ToUTF16("something"), | 229 EXPECT_EQ(base::UTF8ToUTF16("something"), |
228 (stored_passwords.begin()->second)[0].username_value); | 230 (stored_passwords.begin()->second)[0].username_value); |
229 } | 231 } |
OLD | NEW |