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

Side by Side Diff: chrome/browser/ui/passwords/manage_passwords_ui_controller_unittest.cc

Issue 2552263002: Pass InteractionStats by value (Closed)
Patch Set: ={} Created 4 years 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 <map> 5 #include <map>
6 #include <memory> 6 #include <memory>
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 controller()->GetState()); 346 controller()->GetState());
347 EXPECT_FALSE(controller()->opened_bubble()); 347 EXPECT_FALSE(controller()->opened_bubble());
348 348
349 ExpectIconStateIs(password_manager::ui::PENDING_PASSWORD_STATE); 349 ExpectIconStateIs(password_manager::ui::PENDING_PASSWORD_STATE);
350 } 350 }
351 351
352 TEST_F(ManagePasswordsUIControllerTest, PasswordSubmittedBubbleSuppressed) { 352 TEST_F(ManagePasswordsUIControllerTest, PasswordSubmittedBubbleSuppressed) {
353 CreateSmartBubbleFieldTrial(); 353 CreateSmartBubbleFieldTrial();
354 std::unique_ptr<password_manager::PasswordFormManager> test_form_manager( 354 std::unique_ptr<password_manager::PasswordFormManager> test_form_manager(
355 CreateFormManager()); 355 CreateFormManager());
356 password_manager::InteractionsStats stats; 356 std::vector<password_manager::InteractionsStats> stats(1);
357 stats.origin_domain = test_local_form().origin.GetOrigin(); 357 stats[0].origin_domain = test_local_form().origin.GetOrigin();
358 stats.username_value = test_local_form().username_value; 358 stats[0].username_value = test_local_form().username_value;
359 stats.dismissal_count = kGreatDissmisalCount; 359 stats[0].dismissal_count = kGreatDissmisalCount;
360 fetcher().set_stats({&stats}); 360 fetcher().set_stats(stats);
361 test_form_manager->ProvisionallySave( 361 test_form_manager->ProvisionallySave(
362 test_local_form(), 362 test_local_form(),
363 password_manager::PasswordFormManager::IGNORE_OTHER_POSSIBLE_USERNAMES); 363 password_manager::PasswordFormManager::IGNORE_OTHER_POSSIBLE_USERNAMES);
364 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility()); 364 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility());
365 controller()->OnPasswordSubmitted(std::move(test_form_manager)); 365 controller()->OnPasswordSubmitted(std::move(test_form_manager));
366 EXPECT_EQ(password_manager::ui::PENDING_PASSWORD_STATE, 366 EXPECT_EQ(password_manager::ui::PENDING_PASSWORD_STATE,
367 controller()->GetState()); 367 controller()->GetState());
368 EXPECT_FALSE(controller()->opened_bubble()); 368 EXPECT_FALSE(controller()->opened_bubble());
369 ASSERT_TRUE(controller()->GetCurrentInteractionStats()); 369 ASSERT_TRUE(controller()->GetCurrentInteractionStats());
370 EXPECT_EQ(stats, *controller()->GetCurrentInteractionStats()); 370 EXPECT_EQ(stats[0], *controller()->GetCurrentInteractionStats());
371 371
372 ExpectIconStateIs(password_manager::ui::PENDING_PASSWORD_STATE); 372 ExpectIconStateIs(password_manager::ui::PENDING_PASSWORD_STATE);
373 variations::testing::ClearAllVariationParams(); 373 variations::testing::ClearAllVariationParams();
374 } 374 }
375 375
376 TEST_F(ManagePasswordsUIControllerTest, PasswordSubmittedBubbleNotSuppressed) { 376 TEST_F(ManagePasswordsUIControllerTest, PasswordSubmittedBubbleNotSuppressed) {
377 CreateSmartBubbleFieldTrial(); 377 CreateSmartBubbleFieldTrial();
378 std::unique_ptr<password_manager::PasswordFormManager> test_form_manager( 378 std::unique_ptr<password_manager::PasswordFormManager> test_form_manager(
379 CreateFormManager()); 379 CreateFormManager());
380 password_manager::InteractionsStats stats; 380 std::vector<password_manager::InteractionsStats> stats(1);
381 stats.origin_domain = test_local_form().origin.GetOrigin(); 381 stats[0].origin_domain = test_local_form().origin.GetOrigin();
382 stats.username_value = base::ASCIIToUTF16("not my username"); 382 stats[0].username_value = base::ASCIIToUTF16("not my username");
383 stats.dismissal_count = kGreatDissmisalCount; 383 stats[0].dismissal_count = kGreatDissmisalCount;
384 fetcher().set_stats({&stats}); 384 fetcher().set_stats(stats);
385 test_form_manager->ProvisionallySave( 385 test_form_manager->ProvisionallySave(
386 test_local_form(), 386 test_local_form(),
387 password_manager::PasswordFormManager::IGNORE_OTHER_POSSIBLE_USERNAMES); 387 password_manager::PasswordFormManager::IGNORE_OTHER_POSSIBLE_USERNAMES);
388 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility()); 388 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility());
389 controller()->OnPasswordSubmitted(std::move(test_form_manager)); 389 controller()->OnPasswordSubmitted(std::move(test_form_manager));
390 EXPECT_EQ(password_manager::ui::PENDING_PASSWORD_STATE, 390 EXPECT_EQ(password_manager::ui::PENDING_PASSWORD_STATE,
391 controller()->GetState()); 391 controller()->GetState());
392 EXPECT_TRUE(controller()->opened_bubble()); 392 EXPECT_TRUE(controller()->opened_bubble());
393 EXPECT_FALSE(controller()->GetCurrentInteractionStats()); 393 EXPECT_FALSE(controller()->GetCurrentInteractionStats());
394 394
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 // Open the bubble again. 792 // Open the bubble again.
793 local_credentials.emplace_back(new autofill::PasswordForm(test_local_form())); 793 local_credentials.emplace_back(new autofill::PasswordForm(test_local_form()));
794 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility()); 794 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility());
795 controller()->OnAutoSignin(std::move(local_credentials), 795 controller()->OnAutoSignin(std::move(local_credentials),
796 test_local_form().origin); 796 test_local_form().origin);
797 EXPECT_EQ(password_manager::ui::AUTO_SIGNIN_STATE, controller()->GetState()); 797 EXPECT_EQ(password_manager::ui::AUTO_SIGNIN_STATE, controller()->GetState());
798 // Check the delegate is destroyed. Thus, the first bubble has no way to mess 798 // Check the delegate is destroyed. Thus, the first bubble has no way to mess
799 // up with the controller's state. 799 // up with the controller's state.
800 EXPECT_FALSE(proxy_delegate); 800 EXPECT_FALSE(proxy_delegate);
801 } 801 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698