| Index: chrome/browser/ui/views/passwords/manage_passwords_bubble_view_browsertest.cc
|
| diff --git a/chrome/browser/ui/views/passwords/manage_passwords_bubble_view_browsertest.cc b/chrome/browser/ui/views/passwords/manage_passwords_bubble_view_browsertest.cc
|
| index 9e2636e0f3e5f3608aa08403c2d427e18155333a..02c78128d140aa562df53bca7bb6d920a2ac2df7 100644
|
| --- a/chrome/browser/ui/views/passwords/manage_passwords_bubble_view_browsertest.cc
|
| +++ b/chrome/browser/ui/views/passwords/manage_passwords_bubble_view_browsertest.cc
|
| @@ -17,12 +17,34 @@
|
| #include "components/password_manager/core/browser/stub_password_manager_client.h"
|
| #include "content/public/browser/notification_types.h"
|
| #include "content/public/browser/render_view_host.h"
|
| +#include "net/url_request/test_url_fetcher_factory.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| +using testing::Eq;
|
| +using testing::Field;
|
| +using testing::_;
|
| +
|
| namespace {
|
|
|
| const char kDisplayDispositionMetric[] = "PasswordBubble.DisplayDisposition";
|
|
|
| +// A helper class that will create FakeURLFetcher and record the requested URLs.
|
| +class TestURLFetcherCallback {
|
| + public:
|
| + scoped_ptr<net::FakeURLFetcher> CreateURLFetcher(
|
| + const GURL& url,
|
| + net::URLFetcherDelegate* d,
|
| + const std::string& response_data,
|
| + net::HttpStatusCode response_code,
|
| + net::URLRequestStatus::Status status) {
|
| + OnRequestDone(url);
|
| + return scoped_ptr<net::FakeURLFetcher>(new net::FakeURLFetcher(
|
| + url, d, response_data, response_code, status));
|
| + }
|
| +
|
| + MOCK_METHOD1(OnRequestDone, void(const GURL&));
|
| +};
|
| +
|
| } // namespace
|
|
|
| namespace metrics_util = password_manager::metrics_util;
|
| @@ -229,3 +251,31 @@ IN_PROC_BROWSER_TEST_F(ManagePasswordsBubbleViewTest, TwoTabsWithBubble) {
|
| tab_model->ActivateTabAt(1, true);
|
| EXPECT_FALSE(ManagePasswordsBubbleView::IsShowing());
|
| }
|
| +
|
| +IN_PROC_BROWSER_TEST_F(ManagePasswordsBubbleViewTest, ChooseCredential) {
|
| + ScopedVector<autofill::PasswordForm> local_credentials;
|
| + test_form()->display_name = base::ASCIIToUTF16("Peter");
|
| + test_form()->avatar_url = GURL("broken url");
|
| + local_credentials.push_back(new autofill::PasswordForm(*test_form()));
|
| + GURL avatar_url("https://google.com/avatar.png");
|
| + test_form()->avatar_url = avatar_url;
|
| + local_credentials.push_back(new autofill::PasswordForm(*test_form()));
|
| +
|
| + // Prepare to capture the network request.
|
| + TestURLFetcherCallback url_callback;
|
| + net::FakeURLFetcherFactory factory(
|
| + NULL,
|
| + base::Bind(&TestURLFetcherCallback::CreateURLFetcher,
|
| + base::Unretained(&url_callback)));
|
| + factory.SetFakeResponse(avatar_url, std::string(), net::HTTP_OK,
|
| + net::URLRequestStatus::FAILED);
|
| + EXPECT_CALL(url_callback, OnRequestDone(avatar_url));
|
| +
|
| + SetupChooseCredentials(local_credentials.Pass(),
|
| + ScopedVector<autofill::PasswordForm>());
|
| + EXPECT_TRUE(ManagePasswordsBubbleView::IsShowing());
|
| + EXPECT_CALL(*this, OnChooseCredential(
|
| + Field(&password_manager::CredentialInfo::type,
|
| + password_manager::CredentialType::CREDENTIAL_TYPE_EMPTY)));
|
| + ManagePasswordsBubbleView::CloseBubble();
|
| +}
|
|
|