| 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 "components/web_modal/web_contents_modal_dialog_manager.h" | 5 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "components/web_modal/single_web_contents_dialog_manager.h" | 10 #include "components/web_modal/single_web_contents_dialog_manager.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 DialogState state_; | 36 DialogState state_; |
| 37 bool was_shown_; | 37 bool was_shown_; |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 NativeManagerTracker unused_tracker; | 40 NativeManagerTracker unused_tracker; |
| 41 | 41 |
| 42 class TestNativeWebContentsModalDialogManager | 42 class TestNativeWebContentsModalDialogManager |
| 43 : public SingleWebContentsDialogManager { | 43 : public SingleWebContentsDialogManager { |
| 44 public: | 44 public: |
| 45 TestNativeWebContentsModalDialogManager( | 45 TestNativeWebContentsModalDialogManager( |
| 46 NativeWebContentsModalDialog dialog, | 46 gfx::NativeWindow dialog, |
| 47 SingleWebContentsDialogManagerDelegate* delegate, | 47 SingleWebContentsDialogManagerDelegate* delegate, |
| 48 NativeManagerTracker* tracker) | 48 NativeManagerTracker* tracker) |
| 49 : delegate_(delegate), | 49 : delegate_(delegate), |
| 50 dialog_(dialog), | 50 dialog_(dialog), |
| 51 tracker_(tracker) { | 51 tracker_(tracker) { |
| 52 if (tracker_) | 52 if (tracker_) |
| 53 tracker_->SetState(NativeManagerTracker::NOT_SHOWN); | 53 tracker_->SetState(NativeManagerTracker::NOT_SHOWN); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void Show() override { | 56 void Show() override { |
| 57 if (tracker_) | 57 if (tracker_) |
| 58 tracker_->SetState(NativeManagerTracker::SHOWN); | 58 tracker_->SetState(NativeManagerTracker::SHOWN); |
| 59 } | 59 } |
| 60 void Hide() override { | 60 void Hide() override { |
| 61 if (tracker_) | 61 if (tracker_) |
| 62 tracker_->SetState(NativeManagerTracker::HIDDEN); | 62 tracker_->SetState(NativeManagerTracker::HIDDEN); |
| 63 } | 63 } |
| 64 void Close() override { | 64 void Close() override { |
| 65 if (tracker_) | 65 if (tracker_) |
| 66 tracker_->SetState(NativeManagerTracker::CLOSED); | 66 tracker_->SetState(NativeManagerTracker::CLOSED); |
| 67 delegate_->WillClose(dialog_); | 67 delegate_->WillClose(dialog_); |
| 68 } | 68 } |
| 69 void Focus() override {} | 69 void Focus() override {} |
| 70 void Pulse() override {} | 70 void Pulse() override {} |
| 71 void HostChanged(WebContentsModalDialogHost* new_host) override {} | 71 void HostChanged(WebContentsModalDialogHost* new_host) override {} |
| 72 NativeWebContentsModalDialog dialog() override { return dialog_; } | 72 gfx::NativeWindow dialog() override { return dialog_; } |
| 73 | 73 |
| 74 void StopTracking() { | 74 void StopTracking() { |
| 75 tracker_ = NULL; | 75 tracker_ = NULL; |
| 76 } | 76 } |
| 77 | 77 |
| 78 private: | 78 private: |
| 79 SingleWebContentsDialogManagerDelegate* delegate_; | 79 SingleWebContentsDialogManagerDelegate* delegate_; |
| 80 NativeWebContentsModalDialog dialog_; | 80 gfx::NativeWindow dialog_; |
| 81 NativeManagerTracker* tracker_; | 81 NativeManagerTracker* tracker_; |
| 82 | 82 |
| 83 DISALLOW_COPY_AND_ASSIGN(TestNativeWebContentsModalDialogManager); | 83 DISALLOW_COPY_AND_ASSIGN(TestNativeWebContentsModalDialogManager); |
| 84 }; | 84 }; |
| 85 | 85 |
| 86 class WebContentsModalDialogManagerTest | 86 class WebContentsModalDialogManagerTest |
| 87 : public content::RenderViewHostTestHarness { | 87 : public content::RenderViewHostTestHarness { |
| 88 public: | 88 public: |
| 89 WebContentsModalDialogManagerTest() | 89 WebContentsModalDialogManagerTest() |
| 90 : next_dialog_id(1), | 90 : next_dialog_id(1), |
| 91 manager(NULL) { | 91 manager(NULL) { |
| 92 } | 92 } |
| 93 | 93 |
| 94 void SetUp() override { | 94 void SetUp() override { |
| 95 content::RenderViewHostTestHarness::SetUp(); | 95 content::RenderViewHostTestHarness::SetUp(); |
| 96 | 96 |
| 97 delegate.reset(new TestWebContentsModalDialogManagerDelegate); | 97 delegate.reset(new TestWebContentsModalDialogManagerDelegate); |
| 98 WebContentsModalDialogManager::CreateForWebContents(web_contents()); | 98 WebContentsModalDialogManager::CreateForWebContents(web_contents()); |
| 99 manager = WebContentsModalDialogManager::FromWebContents(web_contents()); | 99 manager = WebContentsModalDialogManager::FromWebContents(web_contents()); |
| 100 manager->SetDelegate(delegate.get()); | 100 manager->SetDelegate(delegate.get()); |
| 101 test_api.reset(new WebContentsModalDialogManager::TestApi(manager)); | 101 test_api.reset(new WebContentsModalDialogManager::TestApi(manager)); |
| 102 } | 102 } |
| 103 | 103 |
| 104 void TearDown() override { | 104 void TearDown() override { |
| 105 test_api.reset(); | 105 test_api.reset(); |
| 106 content::RenderViewHostTestHarness::TearDown(); | 106 content::RenderViewHostTestHarness::TearDown(); |
| 107 } | 107 } |
| 108 | 108 |
| 109 protected: | 109 protected: |
| 110 NativeWebContentsModalDialog MakeFakeDialog() { | 110 gfx::NativeWindow MakeFakeDialog() { |
| 111 // WebContentsModalDialogManager treats the NativeWebContentsModalDialog as | 111 // WebContentsModalDialogManager treats the dialog window as an opaque |
| 112 // an opaque type, so creating fake NativeWebContentsModalDialogs using | 112 // type, so creating fake dialog windows using reinterpret_cast is valid. |
| 113 // reinterpret_cast is valid. | 113 return reinterpret_cast<gfx::NativeWindow>(next_dialog_id++); |
| 114 return reinterpret_cast<NativeWebContentsModalDialog>(next_dialog_id++); | |
| 115 } | 114 } |
| 116 | 115 |
| 117 int next_dialog_id; | 116 int next_dialog_id; |
| 118 scoped_ptr<TestWebContentsModalDialogManagerDelegate> delegate; | 117 scoped_ptr<TestWebContentsModalDialogManagerDelegate> delegate; |
| 119 WebContentsModalDialogManager* manager; | 118 WebContentsModalDialogManager* manager; |
| 120 scoped_ptr<WebContentsModalDialogManager::TestApi> test_api; | 119 scoped_ptr<WebContentsModalDialogManager::TestApi> test_api; |
| 121 | 120 |
| 122 DISALLOW_COPY_AND_ASSIGN(WebContentsModalDialogManagerTest); | 121 DISALLOW_COPY_AND_ASSIGN(WebContentsModalDialogManagerTest); |
| 123 }; | 122 }; |
| 124 | 123 |
| 125 SingleWebContentsDialogManager* | 124 SingleWebContentsDialogManager* |
| 126 WebContentsModalDialogManager::CreateNativeWebModalManager( | 125 WebContentsModalDialogManager::CreateNativeWebModalManager( |
| 127 NativeWebContentsModalDialog dialog, | 126 gfx::NativeWindow dialog, |
| 128 SingleWebContentsDialogManagerDelegate* native_delegate) { | 127 SingleWebContentsDialogManagerDelegate* native_delegate) { |
| 129 NOTREACHED(); | 128 NOTREACHED(); |
| 130 return new TestNativeWebContentsModalDialogManager( | 129 return new TestNativeWebContentsModalDialogManager( |
| 131 dialog, | 130 dialog, |
| 132 native_delegate, | 131 native_delegate, |
| 133 &unused_tracker); | 132 &unused_tracker); |
| 134 } | 133 } |
| 135 | 134 |
| 136 // Test that the dialog is shown immediately when the delegate indicates the web | 135 // Test that the dialog is shown immediately when the delegate indicates the web |
| 137 // contents is visible. | 136 // contents is visible. |
| 138 TEST_F(WebContentsModalDialogManagerTest, WebContentsVisible) { | 137 TEST_F(WebContentsModalDialogManagerTest, WebContentsVisible) { |
| 139 // Dialog should be shown while WebContents is visible. | 138 // Dialog should be shown while WebContents is visible. |
| 140 const NativeWebContentsModalDialog dialog = MakeFakeDialog(); | 139 const gfx::NativeWindow dialog = MakeFakeDialog(); |
| 141 | 140 |
| 142 NativeManagerTracker tracker; | 141 NativeManagerTracker tracker; |
| 143 TestNativeWebContentsModalDialogManager* native_manager = | 142 TestNativeWebContentsModalDialogManager* native_manager = |
| 144 new TestNativeWebContentsModalDialogManager(dialog, manager, &tracker); | 143 new TestNativeWebContentsModalDialogManager(dialog, manager, &tracker); |
| 145 manager->ShowDialogWithManager(dialog, | 144 manager->ShowDialogWithManager(dialog, |
| 146 scoped_ptr<SingleWebContentsDialogManager>(native_manager).Pass()); | 145 scoped_ptr<SingleWebContentsDialogManager>(native_manager).Pass()); |
| 147 | 146 |
| 148 EXPECT_EQ(NativeManagerTracker::SHOWN, tracker.state_); | 147 EXPECT_EQ(NativeManagerTracker::SHOWN, tracker.state_); |
| 149 EXPECT_TRUE(manager->IsDialogActive()); | 148 EXPECT_TRUE(manager->IsDialogActive()); |
| 150 EXPECT_TRUE(delegate->web_contents_blocked()); | 149 EXPECT_TRUE(delegate->web_contents_blocked()); |
| 151 EXPECT_TRUE(tracker.was_shown_); | 150 EXPECT_TRUE(tracker.was_shown_); |
| 152 | 151 |
| 153 native_manager->StopTracking(); | 152 native_manager->StopTracking(); |
| 154 } | 153 } |
| 155 | 154 |
| 156 // Test that the dialog is not shown immediately when the delegate indicates the | 155 // Test that the dialog is not shown immediately when the delegate indicates the |
| 157 // web contents is not visible. | 156 // web contents is not visible. |
| 158 TEST_F(WebContentsModalDialogManagerTest, WebContentsNotVisible) { | 157 TEST_F(WebContentsModalDialogManagerTest, WebContentsNotVisible) { |
| 159 // Dialog should not be shown while WebContents is not visible. | 158 // Dialog should not be shown while WebContents is not visible. |
| 160 delegate->set_web_contents_visible(false); | 159 delegate->set_web_contents_visible(false); |
| 161 | 160 |
| 162 const NativeWebContentsModalDialog dialog = MakeFakeDialog(); | 161 const gfx::NativeWindow dialog = MakeFakeDialog(); |
| 163 | 162 |
| 164 NativeManagerTracker tracker; | 163 NativeManagerTracker tracker; |
| 165 TestNativeWebContentsModalDialogManager* native_manager = | 164 TestNativeWebContentsModalDialogManager* native_manager = |
| 166 new TestNativeWebContentsModalDialogManager(dialog, manager, &tracker); | 165 new TestNativeWebContentsModalDialogManager(dialog, manager, &tracker); |
| 167 manager->ShowDialogWithManager(dialog, | 166 manager->ShowDialogWithManager(dialog, |
| 168 scoped_ptr<SingleWebContentsDialogManager>(native_manager).Pass()); | 167 scoped_ptr<SingleWebContentsDialogManager>(native_manager).Pass()); |
| 169 | 168 |
| 170 EXPECT_EQ(NativeManagerTracker::NOT_SHOWN, tracker.state_); | 169 EXPECT_EQ(NativeManagerTracker::NOT_SHOWN, tracker.state_); |
| 171 EXPECT_TRUE(manager->IsDialogActive()); | 170 EXPECT_TRUE(manager->IsDialogActive()); |
| 172 EXPECT_TRUE(delegate->web_contents_blocked()); | 171 EXPECT_TRUE(delegate->web_contents_blocked()); |
| 173 EXPECT_FALSE(tracker.was_shown_); | 172 EXPECT_FALSE(tracker.was_shown_); |
| 174 | 173 |
| 175 native_manager->StopTracking(); | 174 native_manager->StopTracking(); |
| 176 } | 175 } |
| 177 | 176 |
| 178 // Test that only the first of multiple dialogs is shown. | 177 // Test that only the first of multiple dialogs is shown. |
| 179 TEST_F(WebContentsModalDialogManagerTest, ShowDialogs) { | 178 TEST_F(WebContentsModalDialogManagerTest, ShowDialogs) { |
| 180 const NativeWebContentsModalDialog dialog1 = MakeFakeDialog(); | 179 const gfx::NativeWindow dialog1 = MakeFakeDialog(); |
| 181 const NativeWebContentsModalDialog dialog2 = MakeFakeDialog(); | 180 const gfx::NativeWindow dialog2 = MakeFakeDialog(); |
| 182 const NativeWebContentsModalDialog dialog3 = MakeFakeDialog(); | 181 const gfx::NativeWindow dialog3 = MakeFakeDialog(); |
| 183 | 182 |
| 184 NativeManagerTracker tracker1; | 183 NativeManagerTracker tracker1; |
| 185 NativeManagerTracker tracker2; | 184 NativeManagerTracker tracker2; |
| 186 NativeManagerTracker tracker3; | 185 NativeManagerTracker tracker3; |
| 187 TestNativeWebContentsModalDialogManager* native_manager1 = | 186 TestNativeWebContentsModalDialogManager* native_manager1 = |
| 188 new TestNativeWebContentsModalDialogManager(dialog1, manager, &tracker1); | 187 new TestNativeWebContentsModalDialogManager(dialog1, manager, &tracker1); |
| 189 TestNativeWebContentsModalDialogManager* native_manager2 = | 188 TestNativeWebContentsModalDialogManager* native_manager2 = |
| 190 new TestNativeWebContentsModalDialogManager(dialog2, manager, &tracker2); | 189 new TestNativeWebContentsModalDialogManager(dialog2, manager, &tracker2); |
| 191 TestNativeWebContentsModalDialogManager* native_manager3 = | 190 TestNativeWebContentsModalDialogManager* native_manager3 = |
| 192 new TestNativeWebContentsModalDialogManager(dialog3, manager, &tracker3); | 191 new TestNativeWebContentsModalDialogManager(dialog3, manager, &tracker3); |
| 193 manager->ShowDialogWithManager(dialog1, | 192 manager->ShowDialogWithManager(dialog1, |
| 194 scoped_ptr<SingleWebContentsDialogManager>(native_manager1).Pass()); | 193 scoped_ptr<SingleWebContentsDialogManager>(native_manager1).Pass()); |
| 195 manager->ShowDialogWithManager(dialog2, | 194 manager->ShowDialogWithManager(dialog2, |
| 196 scoped_ptr<SingleWebContentsDialogManager>(native_manager2).Pass()); | 195 scoped_ptr<SingleWebContentsDialogManager>(native_manager2).Pass()); |
| 197 manager->ShowDialogWithManager(dialog3, | 196 manager->ShowDialogWithManager(dialog3, |
| 198 scoped_ptr<SingleWebContentsDialogManager>(native_manager3).Pass()); | 197 scoped_ptr<SingleWebContentsDialogManager>(native_manager3).Pass()); |
| 199 | 198 |
| 200 EXPECT_TRUE(delegate->web_contents_blocked()); | 199 EXPECT_TRUE(delegate->web_contents_blocked()); |
| 201 EXPECT_EQ(NativeManagerTracker::SHOWN, tracker1.state_); | 200 EXPECT_EQ(NativeManagerTracker::SHOWN, tracker1.state_); |
| 202 EXPECT_EQ(NativeManagerTracker::NOT_SHOWN, tracker2.state_); | 201 EXPECT_EQ(NativeManagerTracker::NOT_SHOWN, tracker2.state_); |
| 203 EXPECT_EQ(NativeManagerTracker::NOT_SHOWN, tracker3.state_); | 202 EXPECT_EQ(NativeManagerTracker::NOT_SHOWN, tracker3.state_); |
| 204 | 203 |
| 205 native_manager1->StopTracking(); | 204 native_manager1->StopTracking(); |
| 206 native_manager2->StopTracking(); | 205 native_manager2->StopTracking(); |
| 207 native_manager3->StopTracking(); | 206 native_manager3->StopTracking(); |
| 208 } | 207 } |
| 209 | 208 |
| 210 // Test that the dialog is shown/hidden when the WebContents is shown/hidden. | 209 // Test that the dialog is shown/hidden when the WebContents is shown/hidden. |
| 211 TEST_F(WebContentsModalDialogManagerTest, VisibilityObservation) { | 210 TEST_F(WebContentsModalDialogManagerTest, VisibilityObservation) { |
| 212 const NativeWebContentsModalDialog dialog = MakeFakeDialog(); | 211 const gfx::NativeWindow dialog = MakeFakeDialog(); |
| 213 | 212 |
| 214 NativeManagerTracker tracker; | 213 NativeManagerTracker tracker; |
| 215 TestNativeWebContentsModalDialogManager* native_manager = | 214 TestNativeWebContentsModalDialogManager* native_manager = |
| 216 new TestNativeWebContentsModalDialogManager(dialog, manager, &tracker); | 215 new TestNativeWebContentsModalDialogManager(dialog, manager, &tracker); |
| 217 manager->ShowDialogWithManager(dialog, | 216 manager->ShowDialogWithManager(dialog, |
| 218 scoped_ptr<SingleWebContentsDialogManager>(native_manager).Pass()); | 217 scoped_ptr<SingleWebContentsDialogManager>(native_manager).Pass()); |
| 219 | 218 |
| 220 EXPECT_TRUE(manager->IsDialogActive()); | 219 EXPECT_TRUE(manager->IsDialogActive()); |
| 221 EXPECT_TRUE(delegate->web_contents_blocked()); | 220 EXPECT_TRUE(delegate->web_contents_blocked()); |
| 222 EXPECT_EQ(NativeManagerTracker::SHOWN, tracker.state_); | 221 EXPECT_EQ(NativeManagerTracker::SHOWN, tracker.state_); |
| 223 | 222 |
| 224 test_api->WebContentsWasHidden(); | 223 test_api->WebContentsWasHidden(); |
| 225 | 224 |
| 226 EXPECT_TRUE(manager->IsDialogActive()); | 225 EXPECT_TRUE(manager->IsDialogActive()); |
| 227 EXPECT_TRUE(delegate->web_contents_blocked()); | 226 EXPECT_TRUE(delegate->web_contents_blocked()); |
| 228 EXPECT_EQ(NativeManagerTracker::HIDDEN, tracker.state_); | 227 EXPECT_EQ(NativeManagerTracker::HIDDEN, tracker.state_); |
| 229 | 228 |
| 230 test_api->WebContentsWasShown(); | 229 test_api->WebContentsWasShown(); |
| 231 | 230 |
| 232 EXPECT_TRUE(manager->IsDialogActive()); | 231 EXPECT_TRUE(manager->IsDialogActive()); |
| 233 EXPECT_TRUE(delegate->web_contents_blocked()); | 232 EXPECT_TRUE(delegate->web_contents_blocked()); |
| 234 EXPECT_EQ(NativeManagerTracker::SHOWN, tracker.state_); | 233 EXPECT_EQ(NativeManagerTracker::SHOWN, tracker.state_); |
| 235 | 234 |
| 236 native_manager->StopTracking(); | 235 native_manager->StopTracking(); |
| 237 } | 236 } |
| 238 | 237 |
| 239 // Test that attaching an interstitial page closes all dialogs. | 238 // Test that attaching an interstitial page closes all dialogs. |
| 240 TEST_F(WebContentsModalDialogManagerTest, InterstitialPage) { | 239 TEST_F(WebContentsModalDialogManagerTest, InterstitialPage) { |
| 241 const NativeWebContentsModalDialog dialog1 = MakeFakeDialog(); | 240 const gfx::NativeWindow dialog1 = MakeFakeDialog(); |
| 242 const NativeWebContentsModalDialog dialog2 = MakeFakeDialog(); | 241 const gfx::NativeWindow dialog2 = MakeFakeDialog(); |
| 243 | 242 |
| 244 NativeManagerTracker tracker1; | 243 NativeManagerTracker tracker1; |
| 245 NativeManagerTracker tracker2; | 244 NativeManagerTracker tracker2; |
| 246 TestNativeWebContentsModalDialogManager* native_manager1 = | 245 TestNativeWebContentsModalDialogManager* native_manager1 = |
| 247 new TestNativeWebContentsModalDialogManager(dialog1, manager, &tracker1); | 246 new TestNativeWebContentsModalDialogManager(dialog1, manager, &tracker1); |
| 248 TestNativeWebContentsModalDialogManager* native_manager2 = | 247 TestNativeWebContentsModalDialogManager* native_manager2 = |
| 249 new TestNativeWebContentsModalDialogManager(dialog2, manager, &tracker2); | 248 new TestNativeWebContentsModalDialogManager(dialog2, manager, &tracker2); |
| 250 manager->ShowDialogWithManager(dialog1, | 249 manager->ShowDialogWithManager(dialog1, |
| 251 scoped_ptr<SingleWebContentsDialogManager>(native_manager1).Pass()); | 250 scoped_ptr<SingleWebContentsDialogManager>(native_manager1).Pass()); |
| 252 manager->ShowDialogWithManager(dialog2, | 251 manager->ShowDialogWithManager(dialog2, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 269 native_manager1->StopTracking(); | 268 native_manager1->StopTracking(); |
| 270 native_manager2->StopTracking(); | 269 native_manager2->StopTracking(); |
| 271 #endif | 270 #endif |
| 272 } | 271 } |
| 273 | 272 |
| 274 | 273 |
| 275 // Test that the first dialog is always shown, regardless of the order in which | 274 // Test that the first dialog is always shown, regardless of the order in which |
| 276 // dialogs are closed. | 275 // dialogs are closed. |
| 277 TEST_F(WebContentsModalDialogManagerTest, CloseDialogs) { | 276 TEST_F(WebContentsModalDialogManagerTest, CloseDialogs) { |
| 278 // The front dialog is always shown regardless of dialog close order. | 277 // The front dialog is always shown regardless of dialog close order. |
| 279 const NativeWebContentsModalDialog dialog1 = MakeFakeDialog(); | 278 const gfx::NativeWindow dialog1 = MakeFakeDialog(); |
| 280 const NativeWebContentsModalDialog dialog2 = MakeFakeDialog(); | 279 const gfx::NativeWindow dialog2 = MakeFakeDialog(); |
| 281 const NativeWebContentsModalDialog dialog3 = MakeFakeDialog(); | 280 const gfx::NativeWindow dialog3 = MakeFakeDialog(); |
| 282 const NativeWebContentsModalDialog dialog4 = MakeFakeDialog(); | 281 const gfx::NativeWindow dialog4 = MakeFakeDialog(); |
| 283 | 282 |
| 284 NativeManagerTracker tracker1; | 283 NativeManagerTracker tracker1; |
| 285 NativeManagerTracker tracker2; | 284 NativeManagerTracker tracker2; |
| 286 NativeManagerTracker tracker3; | 285 NativeManagerTracker tracker3; |
| 287 NativeManagerTracker tracker4; | 286 NativeManagerTracker tracker4; |
| 288 TestNativeWebContentsModalDialogManager* native_manager1 = | 287 TestNativeWebContentsModalDialogManager* native_manager1 = |
| 289 new TestNativeWebContentsModalDialogManager(dialog1, manager, &tracker1); | 288 new TestNativeWebContentsModalDialogManager(dialog1, manager, &tracker1); |
| 290 TestNativeWebContentsModalDialogManager* native_manager2 = | 289 TestNativeWebContentsModalDialogManager* native_manager2 = |
| 291 new TestNativeWebContentsModalDialogManager(dialog2, manager, &tracker2); | 290 new TestNativeWebContentsModalDialogManager(dialog2, manager, &tracker2); |
| 292 TestNativeWebContentsModalDialogManager* native_manager3 = | 291 TestNativeWebContentsModalDialogManager* native_manager3 = |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 EXPECT_FALSE(tracker3.was_shown_); | 343 EXPECT_FALSE(tracker3.was_shown_); |
| 345 EXPECT_TRUE(tracker4.was_shown_); | 344 EXPECT_TRUE(tracker4.was_shown_); |
| 346 } | 345 } |
| 347 | 346 |
| 348 // Test that CloseAllDialogs does what it says. | 347 // Test that CloseAllDialogs does what it says. |
| 349 TEST_F(WebContentsModalDialogManagerTest, CloseAllDialogs) { | 348 TEST_F(WebContentsModalDialogManagerTest, CloseAllDialogs) { |
| 350 const int kWindowCount = 4; | 349 const int kWindowCount = 4; |
| 351 NativeManagerTracker trackers[kWindowCount]; | 350 NativeManagerTracker trackers[kWindowCount]; |
| 352 TestNativeWebContentsModalDialogManager* native_managers[kWindowCount]; | 351 TestNativeWebContentsModalDialogManager* native_managers[kWindowCount]; |
| 353 for (int i = 0; i < kWindowCount; i++) { | 352 for (int i = 0; i < kWindowCount; i++) { |
| 354 const NativeWebContentsModalDialog dialog = MakeFakeDialog(); | 353 const gfx::NativeWindow dialog = MakeFakeDialog(); |
| 355 native_managers[i] = | 354 native_managers[i] = |
| 356 new TestNativeWebContentsModalDialogManager( | 355 new TestNativeWebContentsModalDialogManager( |
| 357 dialog, manager, &(trackers[i])); | 356 dialog, manager, &(trackers[i])); |
| 358 manager->ShowDialogWithManager(dialog, | 357 manager->ShowDialogWithManager(dialog, |
| 359 scoped_ptr<SingleWebContentsDialogManager>( | 358 scoped_ptr<SingleWebContentsDialogManager>( |
| 360 native_managers[i]).Pass()); | 359 native_managers[i]).Pass()); |
| 361 } | 360 } |
| 362 | 361 |
| 363 for (int i = 0; i < kWindowCount; i++) | 362 for (int i = 0; i < kWindowCount; i++) |
| 364 EXPECT_NE(NativeManagerTracker::CLOSED, trackers[i].state_); | 363 EXPECT_NE(NativeManagerTracker::CLOSED, trackers[i].state_); |
| 365 | 364 |
| 366 test_api->CloseAllDialogs(); | 365 test_api->CloseAllDialogs(); |
| 367 | 366 |
| 368 EXPECT_FALSE(delegate->web_contents_blocked()); | 367 EXPECT_FALSE(delegate->web_contents_blocked()); |
| 369 EXPECT_FALSE(manager->IsDialogActive()); | 368 EXPECT_FALSE(manager->IsDialogActive()); |
| 370 for (int i = 0; i < kWindowCount; i++) | 369 for (int i = 0; i < kWindowCount; i++) |
| 371 EXPECT_EQ(NativeManagerTracker::CLOSED, trackers[i].state_); | 370 EXPECT_EQ(NativeManagerTracker::CLOSED, trackers[i].state_); |
| 372 } | 371 } |
| 373 | 372 |
| 374 } // namespace web_modal | 373 } // namespace web_modal |
| OLD | NEW |