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

Side by Side Diff: chrome/browser/ui/views/passwords/manage_passwords_bubble_view_browsertest.cc

Issue 952023002: Credential Manager API: pop up the new "Manage accounts" bubble. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix the test Created 5 years, 9 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 unified diff | Download patch
OLDNEW
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 "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" 5 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h"
6 6
7 #include "base/command_line.h"
7 #include "base/metrics/histogram_samples.h" 8 #include "base/metrics/histogram_samples.h"
8 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/passwords/manage_passwords_test.h" 10 #include "chrome/browser/ui/passwords/manage_passwords_test.h"
11 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h"
10 #include "chrome/browser/ui/tabs/tab_strip_model.h" 12 #include "chrome/browser/ui/tabs/tab_strip_model.h"
11 #include "chrome/browser/ui/views/frame/browser_view.h" 13 #include "chrome/browser/ui/views/frame/browser_view.h"
12 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" 14 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h"
13 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h" 15 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h"
14 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" 16 #include "chrome/browser/ui/views/toolbar/toolbar_view.h"
15 #include "chrome/test/base/interactive_test_utils.h" 17 #include "chrome/test/base/interactive_test_utils.h"
16 #include "components/password_manager/core/browser/password_manager_metrics_util .h" 18 #include "components/password_manager/core/browser/password_manager_metrics_util .h"
17 #include "components/password_manager/core/browser/stub_password_manager_client. h" 19 #include "components/password_manager/core/browser/stub_password_manager_client. h"
18 #include "content/public/browser/notification_types.h" 20 #include "content/public/browser/notification_types.h"
19 #include "content/public/browser/render_view_host.h" 21 #include "content/public/browser/render_view_host.h"
22 #include "content/public/common/content_switches.h"
20 #include "net/url_request/test_url_fetcher_factory.h" 23 #include "net/url_request/test_url_fetcher_factory.h"
21 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
22 25
23 using testing::Eq; 26 using testing::Eq;
24 using testing::Field; 27 using testing::Field;
25 using testing::_; 28 using testing::_;
26 29
27 namespace { 30 namespace {
28 31
29 const char kDisplayDispositionMetric[] = "PasswordBubble.DisplayDisposition"; 32 const char kDisplayDispositionMetric[] = "PasswordBubble.DisplayDisposition";
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 SetupChooseCredentials(local_credentials.Pass(), federated_credentials.Pass(), 290 SetupChooseCredentials(local_credentials.Pass(), federated_credentials.Pass(),
288 origin); 291 origin);
289 EXPECT_TRUE(ManagePasswordsBubbleView::IsShowing()); 292 EXPECT_TRUE(ManagePasswordsBubbleView::IsShowing());
290 EXPECT_CALL(*this, OnChooseCredential( 293 EXPECT_CALL(*this, OnChooseCredential(
291 Field(&password_manager::CredentialInfo::type, 294 Field(&password_manager::CredentialInfo::type,
292 password_manager::CredentialType::CREDENTIAL_TYPE_EMPTY))); 295 password_manager::CredentialType::CREDENTIAL_TYPE_EMPTY)));
293 ManagePasswordsBubbleView::CloseBubble(); 296 ManagePasswordsBubbleView::CloseBubble();
294 } 297 }
295 298
296 IN_PROC_BROWSER_TEST_F(ManagePasswordsBubbleViewTest, AutoSignin) { 299 IN_PROC_BROWSER_TEST_F(ManagePasswordsBubbleViewTest, AutoSignin) {
300 // The switch enables the new UI.
301 base::CommandLine::ForCurrentProcess()->AppendSwitch(
302 switches::kEnableCredentialManagerAPI);
297 ScopedVector<autofill::PasswordForm> local_credentials; 303 ScopedVector<autofill::PasswordForm> local_credentials;
298 test_form()->origin = GURL("https://example.com"); 304 test_form()->origin = GURL("https://example.com");
299 test_form()->display_name = base::ASCIIToUTF16("Peter"); 305 test_form()->display_name = base::ASCIIToUTF16("Peter");
300 test_form()->username_value = base::ASCIIToUTF16("pet12@gmail.com"); 306 test_form()->username_value = base::ASCIIToUTF16("pet12@gmail.com");
301 GURL avatar_url("https://google.com/avatar.png"); 307 GURL avatar_url("https://google.com/avatar.png");
302 test_form()->avatar_url = avatar_url; 308 test_form()->avatar_url = avatar_url;
303 local_credentials.push_back(new autofill::PasswordForm(*test_form())); 309 local_credentials.push_back(new autofill::PasswordForm(*test_form()));
304 310
305 // Prepare to capture the network request. 311 // Prepare to capture the network request.
306 TestURLFetcherCallback url_callback; 312 TestURLFetcherCallback url_callback;
307 net::FakeURLFetcherFactory factory( 313 net::FakeURLFetcherFactory factory(
308 NULL, 314 NULL,
309 base::Bind(&TestURLFetcherCallback::CreateURLFetcher, 315 base::Bind(&TestURLFetcherCallback::CreateURLFetcher,
310 base::Unretained(&url_callback))); 316 base::Unretained(&url_callback)));
311 factory.SetFakeResponse(avatar_url, std::string(), net::HTTP_OK, 317 factory.SetFakeResponse(avatar_url, std::string(), net::HTTP_OK,
312 net::URLRequestStatus::FAILED); 318 net::URLRequestStatus::FAILED);
313 EXPECT_CALL(url_callback, OnRequestDone(avatar_url)); 319 EXPECT_CALL(url_callback, OnRequestDone(avatar_url));
314 320
315 SetupAutoSignin(local_credentials.Pass()); 321 SetupAutoSignin(local_credentials.Pass());
316 EXPECT_TRUE(ManagePasswordsBubbleView::IsShowing()); 322 EXPECT_TRUE(ManagePasswordsBubbleView::IsShowing());
323 ::testing::Mock::VerifyAndClearExpectations(&url_callback);
324
325 ManagePasswordsBubbleView::CloseBubble();
326 EXPECT_FALSE(ManagePasswordsBubbleView::IsShowing());
327 content::RunAllPendingInMessageLoop();
328
329 // Open the bubble to manage accounts.
330 EXPECT_EQ(password_manager::ui::MANAGE_STATE, GetController()->state());
331 EXPECT_CALL(url_callback, OnRequestDone(avatar_url));
332 ManagePasswordsBubbleView::ShowBubble(
333 browser()->tab_strip_model()->GetActiveWebContents(),
334 ManagePasswordsBubble::USER_ACTION);
335 EXPECT_TRUE(ManagePasswordsBubbleView::IsShowing());
317 } 336 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698