| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/content_settings/permission_queue_controller.h" | 5 #include "chrome/browser/content_settings/permission_queue_controller.h" |
| 6 | 6 |
| 7 #include "base/synchronization/waitable_event.h" | 7 #include "base/synchronization/waitable_event.h" |
| 8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
| 9 #include "chrome/browser/infobars/infobar_service.h" | 9 #include "chrome/browser/infobars/infobar_service.h" |
| 10 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 10 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 // the controller. If the controller has another infobar queued, it should | 88 // the controller. If the controller has another infobar queued, it should |
| 89 // maintain its registration for notifications with the helper, but on the | 89 // maintain its registration for notifications with the helper, but on the |
| 90 // last infobar cancellation it should unregister for notifications. | 90 // last infobar cancellation it should unregister for notifications. |
| 91 // | 91 // |
| 92 // What we don't want is for the controller to unregister and then re-register | 92 // What we don't want is for the controller to unregister and then re-register |
| 93 // for notifications, which can lead to getting notified multiple times. This | 93 // for notifications, which can lead to getting notified multiple times. This |
| 94 // test checks that in the case where the controller should remain registered | 94 // test checks that in the case where the controller should remain registered |
| 95 // for notifications, it gets notified exactly once." | 95 // for notifications, it gets notified exactly once." |
| 96 ObservationCountingQueueController queue_controller(profile()); | 96 ObservationCountingQueueController queue_controller(profile()); |
| 97 GURL url("http://www.example.com/geolocation"); | 97 GURL url("http://www.example.com/geolocation"); |
| 98 base::Callback<void(bool)> callback; | 98 base::Callback<void(ContentSetting)> callback; |
| 99 queue_controller.CreateInfoBarRequest( | 99 queue_controller.CreateInfoBarRequest( |
| 100 RequestID(0), url, url, callback); | 100 RequestID(0), url, url, callback); |
| 101 queue_controller.CreateInfoBarRequest( | 101 queue_controller.CreateInfoBarRequest( |
| 102 RequestID(1), url, url, callback); | 102 RequestID(1), url, url, callback); |
| 103 queue_controller.CancelInfoBarRequest(RequestID(0)); | 103 queue_controller.CancelInfoBarRequest(RequestID(0)); |
| 104 EXPECT_EQ(1, queue_controller.call_count()); | 104 EXPECT_EQ(1, queue_controller.call_count()); |
| 105 }; | 105 } |
| 106 | 106 |
| 107 TEST_F(PermissionQueueControllerTests, FailOnBadPattern) { | 107 TEST_F(PermissionQueueControllerTests, FailOnBadPattern) { |
| 108 ObservationCountingQueueController queue_controller(profile()); | 108 ObservationCountingQueueController queue_controller(profile()); |
| 109 GURL url("chrome://settings"); | 109 GURL url("chrome://settings"); |
| 110 base::Callback<void(bool)> callback; | 110 base::Callback<void(ContentSetting)> callback; |
| 111 queue_controller.CreateInfoBarRequest( | 111 queue_controller.CreateInfoBarRequest( |
| 112 RequestID(0), url, url, callback); | 112 RequestID(0), url, url, callback); |
| 113 queue_controller.CancelInfoBarRequest(RequestID(0)); | 113 queue_controller.CancelInfoBarRequest(RequestID(0)); |
| 114 EXPECT_EQ(0, queue_controller.call_count()); | 114 EXPECT_EQ(0, queue_controller.call_count()); |
| 115 }; | 115 } |
| OLD | NEW |