| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/password_manager/password_manager_test_base.h" | 5 #include "chrome/browser/password_manager/password_manager_test_base.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 } else if (!render_frame_host->GetParent()) { | 50 } else if (!render_frame_host->GetParent()) { |
| 51 message_loop_runner_->Quit(); | 51 message_loop_runner_->Quit(); |
| 52 } | 52 } |
| 53 } | 53 } |
| 54 | 54 |
| 55 void NavigationObserver::Wait() { | 55 void NavigationObserver::Wait() { |
| 56 message_loop_runner_->Run(); | 56 message_loop_runner_->Run(); |
| 57 } | 57 } |
| 58 | 58 |
| 59 BubbleObserver::BubbleObserver(content::WebContents* web_contents) | 59 BubbleObserver::BubbleObserver(content::WebContents* web_contents) |
| 60 : passwords_model_delegate_( | 60 : passwords_ui_controller_( |
| 61 PasswordsModelDelegateFromWebContents(web_contents)) {} | 61 ManagePasswordsUIController::FromWebContents(web_contents)) {} |
| 62 | 62 |
| 63 bool BubbleObserver::IsShowingSavePrompt() const { | 63 bool BubbleObserver::IsShowingSavePrompt() const { |
| 64 return passwords_model_delegate_->GetState() == | 64 return passwords_ui_controller_->GetState() == |
| 65 password_manager::ui::PENDING_PASSWORD_STATE; | 65 password_manager::ui::PENDING_PASSWORD_STATE; |
| 66 } | 66 } |
| 67 | 67 |
| 68 bool BubbleObserver::IsShowingUpdatePrompt() const { | 68 bool BubbleObserver::IsShowingUpdatePrompt() const { |
| 69 return passwords_model_delegate_->GetState() == | 69 return passwords_ui_controller_->GetState() == |
| 70 password_manager::ui::PENDING_PASSWORD_UPDATE_STATE; | 70 password_manager::ui::PENDING_PASSWORD_UPDATE_STATE; |
| 71 } | 71 } |
| 72 | 72 |
| 73 void BubbleObserver::Dismiss() const { | 73 void BubbleObserver::Dismiss() const { |
| 74 passwords_model_delegate_->OnBubbleHidden(); | 74 passwords_ui_controller_->OnBubbleHidden(); |
| 75 // Navigate away to reset the state to inactive. | 75 // Navigate away to reset the state to inactive. |
| 76 static_cast<content::WebContentsObserver*>( | 76 static_cast<content::WebContentsObserver*>(passwords_ui_controller_) |
| 77 static_cast<ManagePasswordsUIController*>(passwords_model_delegate_)) | 77 ->DidNavigateMainFrame(content::LoadCommittedDetails(), |
| 78 ->DidNavigateMainFrame(content::LoadCommittedDetails(), | 78 content::FrameNavigateParams()); |
| 79 content::FrameNavigateParams()); | |
| 80 ASSERT_EQ(password_manager::ui::INACTIVE_STATE, | 79 ASSERT_EQ(password_manager::ui::INACTIVE_STATE, |
| 81 passwords_model_delegate_->GetState()); | 80 passwords_ui_controller_->GetState()); |
| 82 } | 81 } |
| 83 | 82 |
| 84 void BubbleObserver::AcceptSavePrompt() const { | 83 void BubbleObserver::AcceptSavePrompt() const { |
| 85 ASSERT_TRUE(IsShowingSavePrompt()); | 84 ASSERT_TRUE(IsShowingSavePrompt()); |
| 86 passwords_model_delegate_->SavePassword(); | 85 passwords_ui_controller_->SavePassword(); |
| 87 EXPECT_FALSE(IsShowingSavePrompt()); | 86 EXPECT_FALSE(IsShowingSavePrompt()); |
| 88 } | 87 } |
| 89 | 88 |
| 90 void BubbleObserver::AcceptUpdatePrompt( | 89 void BubbleObserver::AcceptUpdatePrompt( |
| 91 const autofill::PasswordForm& form) const { | 90 const autofill::PasswordForm& form) const { |
| 92 ASSERT_TRUE(IsShowingUpdatePrompt()); | 91 ASSERT_TRUE(IsShowingUpdatePrompt()); |
| 93 passwords_model_delegate_->UpdatePassword(form); | 92 passwords_ui_controller_->UpdatePassword(form); |
| 94 EXPECT_FALSE(IsShowingUpdatePrompt()); | 93 EXPECT_FALSE(IsShowingUpdatePrompt()); |
| 95 } | 94 } |
| 96 | 95 |
| 97 PasswordManagerBrowserTestBase::PasswordManagerBrowserTestBase() { | 96 PasswordManagerBrowserTestBase::PasswordManagerBrowserTestBase() { |
| 98 } | 97 } |
| 99 PasswordManagerBrowserTestBase::~PasswordManagerBrowserTestBase() { | 98 PasswordManagerBrowserTestBase::~PasswordManagerBrowserTestBase() { |
| 100 } | 99 } |
| 101 | 100 |
| 102 void PasswordManagerBrowserTestBase::SetUpOnMainThread() { | 101 void PasswordManagerBrowserTestBase::SetUpOnMainThread() { |
| 103 // Use TestPasswordStore to remove a possible race. Normally the | 102 // Use TestPasswordStore to remove a possible race. Normally the |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 " var element = document.getElementById('%s');" | 249 " var element = document.getElementById('%s');" |
| 251 "window.domAutomationController.send(element && element.value == '%s');", | 250 "window.domAutomationController.send(element && element.value == '%s');", |
| 252 iframe_id.c_str(), iframe_id.c_str(), element_id.c_str(), | 251 iframe_id.c_str(), iframe_id.c_str(), element_id.c_str(), |
| 253 element_id.c_str(), expected_value.c_str()); | 252 element_id.c_str(), expected_value.c_str()); |
| 254 bool return_value = false; | 253 bool return_value = false; |
| 255 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 254 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 256 RenderViewHost(), value_check_script, &return_value)); | 255 RenderViewHost(), value_check_script, &return_value)); |
| 257 EXPECT_TRUE(return_value) << "element_id = " << element_id | 256 EXPECT_TRUE(return_value) << "element_id = " << element_id |
| 258 << ", expected_value = " << expected_value; | 257 << ", expected_value = " << expected_value; |
| 259 } | 258 } |
| OLD | NEW |