OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/website_settings/website_settings.h" | 5 #include "chrome/browser/ui/website_settings/website_settings.h" |
6 | 6 |
7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/string16.h" | 9 #include "base/string16.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 website_settings()->site_connection_status()); | 361 website_settings()->site_connection_status()); |
362 EXPECT_EQ(WebsiteSettings::SITE_IDENTITY_STATUS_CERT, | 362 EXPECT_EQ(WebsiteSettings::SITE_IDENTITY_STATUS_CERT, |
363 website_settings()->site_identity_status()); | 363 website_settings()->site_identity_status()); |
364 EXPECT_EQ(string16(), website_settings()->organization_name()); | 364 EXPECT_EQ(string16(), website_settings()->organization_name()); |
365 } | 365 } |
366 | 366 |
367 TEST_F(WebsiteSettingsTest, NoInfoBar) { | 367 TEST_F(WebsiteSettingsTest, NoInfoBar) { |
368 SetDefaultUIExpectations(mock_ui()); | 368 SetDefaultUIExpectations(mock_ui()); |
369 EXPECT_CALL(*mock_ui(), SetSelectedTab( | 369 EXPECT_CALL(*mock_ui(), SetSelectedTab( |
370 WebsiteSettingsUI::TAB_ID_PERMISSIONS)); | 370 WebsiteSettingsUI::TAB_ID_PERMISSIONS)); |
371 EXPECT_EQ(0u, infobar_service()->GetInfoBarCount()); | 371 EXPECT_EQ(0u, infobar_service()->infobar_count()); |
372 website_settings()->OnUIClosing(); | 372 website_settings()->OnUIClosing(); |
373 EXPECT_EQ(0u, infobar_service()->GetInfoBarCount()); | 373 EXPECT_EQ(0u, infobar_service()->infobar_count()); |
374 } | 374 } |
375 | 375 |
376 TEST_F(WebsiteSettingsTest, ShowInfoBar) { | 376 TEST_F(WebsiteSettingsTest, ShowInfoBar) { |
377 EXPECT_CALL(*mock_ui(), SetIdentityInfo(_)); | 377 EXPECT_CALL(*mock_ui(), SetIdentityInfo(_)); |
378 EXPECT_CALL(*mock_ui(), SetCookieInfo(_)); | 378 EXPECT_CALL(*mock_ui(), SetCookieInfo(_)); |
379 EXPECT_CALL(*mock_ui(), SetFirstVisit(string16())); | 379 EXPECT_CALL(*mock_ui(), SetFirstVisit(string16())); |
380 | 380 |
381 // SetPermissionInfo() is called once initially, and then again every time | 381 // SetPermissionInfo() is called once initially, and then again every time |
382 // OnSitePermissionChanged() is called. | 382 // OnSitePermissionChanged() is called. |
383 // TODO(markusheintz): This is a temporary hack to fix issue: | 383 // TODO(markusheintz): This is a temporary hack to fix issue: |
384 // http://crbug.com/144203. | 384 // http://crbug.com/144203. |
385 #if defined(OS_MACOSX) | 385 #if defined(OS_MACOSX) |
386 EXPECT_CALL(*mock_ui(), SetPermissionInfo(_)).Times(2); | 386 EXPECT_CALL(*mock_ui(), SetPermissionInfo(_)).Times(2); |
387 #else | 387 #else |
388 EXPECT_CALL(*mock_ui(), SetPermissionInfo(_)).Times(1); | 388 EXPECT_CALL(*mock_ui(), SetPermissionInfo(_)).Times(1); |
389 #endif | 389 #endif |
390 | 390 |
391 EXPECT_CALL(*mock_ui(), SetSelectedTab( | 391 EXPECT_CALL(*mock_ui(), SetSelectedTab( |
392 WebsiteSettingsUI::TAB_ID_PERMISSIONS)); | 392 WebsiteSettingsUI::TAB_ID_PERMISSIONS)); |
393 EXPECT_EQ(0u, infobar_service()->GetInfoBarCount()); | 393 EXPECT_EQ(0u, infobar_service()->infobar_count()); |
394 website_settings()->OnSitePermissionChanged( | 394 website_settings()->OnSitePermissionChanged( |
395 CONTENT_SETTINGS_TYPE_GEOLOCATION, CONTENT_SETTING_ALLOW); | 395 CONTENT_SETTINGS_TYPE_GEOLOCATION, CONTENT_SETTING_ALLOW); |
396 website_settings()->OnUIClosing(); | 396 website_settings()->OnUIClosing(); |
397 EXPECT_EQ(1u, infobar_service()->GetInfoBarCount()); | 397 EXPECT_EQ(1u, infobar_service()->infobar_count()); |
398 | 398 |
399 // Removing an |InfoBarDelegate| from the |InfoBarService| does not delete | 399 // Removing an |InfoBarDelegate| from the |InfoBarService| does not delete |
400 // it. Hence the |delegate| must be cleaned up after it was removed from the | 400 // it. Hence the |delegate| must be cleaned up after it was removed from the |
401 // |infobar_service|. | 401 // |infobar_service|. |
402 scoped_ptr<InfoBarDelegate> delegate( | 402 scoped_ptr<InfoBarDelegate> delegate(infobar_service()->infobar_at(0)); |
403 infobar_service()->GetInfoBarDelegateAt(0)); | |
404 infobar_service()->RemoveInfoBar(delegate.get()); | 403 infobar_service()->RemoveInfoBar(delegate.get()); |
405 } | 404 } |
OLD | NEW |