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