+#if defined(OS_MACOSX) && !defined(OS_IOS)
+TEST_F(PersonalDataManagerTest, ShowAddressBookPrompt) {
+ EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()).Times(2);
+
+ AutofillType type(ADDRESS_HOME_STREET_ADDRESS);
+
+ prefs_->SetBoolean(prefs::kAutofillEnabled, false);
+ EXPECT_FALSE(personal_data_->ShouldShowAccessAddressBookSuggestion(type));
+
+ prefs_->SetBoolean(prefs::kAutofillEnabled, true);
+ EXPECT_TRUE(personal_data_->ShouldShowAccessAddressBookSuggestion(type));
+
+ // Adding an Autofill Profile should prevent the prompt from appearing.
+ AutofillProfile profile(base::GenerateGUID(), "https://www.example.com/");
+ test::SetProfileInfo(&profile,
+ "Marion", "Mitchell", "Morrison",
+ "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA",
+ "91601", "US", "12345678910");
+ personal_data_->AddProfile(profile);
+
+ EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged())
+ .WillOnce(QuitMainMessageLoop());
+ base::MessageLoop::current()->Run();
+
+ EXPECT_FALSE(personal_data_->ShouldShowAccessAddressBookSuggestion(type));
+}
+
+// Tests that the logic to show the access Address Book prompt respects the
+// preference that indicates the total number of times the prompt has already
+// been shown.
+TEST_F(PersonalDataManagerTest, MaxTimesToShowAddressBookPrompt) {
+ EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()).Times(1);
+
+ AutofillType type(ADDRESS_HOME_STREET_ADDRESS);
+
+ prefs_->SetBoolean(prefs::kAutofillEnabled, true);
+ EXPECT_TRUE(personal_data_->ShouldShowAccessAddressBookSuggestion(type));
+
+ prefs_->SetInteger(prefs::kAutofillMacAddressBookShowedCount, 4);
+ EXPECT_TRUE(personal_data_->ShouldShowAccessAddressBookSuggestion(type));
+
+ prefs_->SetInteger(prefs::kAutofillMacAddressBookShowedCount, 6);
+ EXPECT_FALSE(personal_data_->ShouldShowAccessAddressBookSuggestion(type));
+}
+#endif // defined(OS_MACOSX) && !defined(OS_IOS)
+