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 <algorithm> | 5 #include <algorithm> |
6 #include <iterator> | 6 #include <iterator> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 const base::Callback<void(webkit_glue::WebIntentReplyType)>&) OVERRIDE { | 193 const base::Callback<void(webkit_glue::WebIntentReplyType)>&) OVERRIDE { |
194 } | 194 } |
195 | 195 |
196 webkit_glue::WebIntentData intent_; | 196 webkit_glue::WebIntentData intent_; |
197 bool dispatched_; | 197 bool dispatched_; |
198 bool replied_; | 198 bool replied_; |
199 }; | 199 }; |
200 | 200 |
201 class WebIntentPickerControllerBrowserTest : public InProcessBrowserTest { | 201 class WebIntentPickerControllerBrowserTest : public InProcessBrowserTest { |
202 protected: | 202 protected: |
203 typedef WebIntentPickerModel::Disposition Disposition; | |
204 | |
205 WebIntentPickerControllerBrowserTest() {} | 203 WebIntentPickerControllerBrowserTest() {} |
206 | 204 |
207 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 205 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
208 // We start the test server now instead of in | 206 // We start the test server now instead of in |
209 // SetUpInProcessBrowserTestFixture so that we can get its port number. | 207 // SetUpInProcessBrowserTestFixture so that we can get its port number. |
210 ASSERT_TRUE(test_server()->Start()); | 208 ASSERT_TRUE(test_server()->Start()); |
211 | 209 |
212 net::HostPortPair host_port = test_server()->host_port_pair(); | 210 net::HostPortPair host_port = test_server()->host_port_pair(); |
213 command_line->AppendSwitchASCII( | 211 command_line->AppendSwitchASCII( |
214 switches::kAppsGalleryDownloadURL, | 212 switches::kAppsGalleryDownloadURL, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 default_service.user_date = 1000000; | 297 default_service.user_date = 1000000; |
300 default_service.service_url = url; | 298 default_service.service_url = url; |
301 web_data_service_->AddDefaultWebIntentService(default_service); | 299 web_data_service_->AddDefaultWebIntentService(default_service); |
302 } | 300 } |
303 | 301 |
304 void OnSendReturnMessage( | 302 void OnSendReturnMessage( |
305 webkit_glue::WebIntentReplyType reply_type) { | 303 webkit_glue::WebIntentReplyType reply_type) { |
306 controller_->OnSendReturnMessage(reply_type); | 304 controller_->OnSendReturnMessage(reply_type); |
307 } | 305 } |
308 | 306 |
309 void OnServiceChosen(const GURL& url, Disposition disposition) { | 307 void OnServiceChosen( |
| 308 const GURL& url, |
| 309 webkit_glue::WebIntentServiceData::Disposition disposition) { |
310 controller_->OnServiceChosen(url, disposition); | 310 controller_->OnServiceChosen(url, disposition); |
311 } | 311 } |
312 | 312 |
313 void OnCancelled() { | 313 void OnCancelled() { |
314 controller_->OnPickerClosed(); | 314 controller_->OnPickerClosed(); |
315 } | 315 } |
316 | 316 |
317 void OnExtensionInstallRequested(const std::string& extension_id) { | 317 void OnExtensionInstallRequested(const std::string& extension_id) { |
318 controller_->OnExtensionInstallRequested(extension_id); | 318 controller_->OnExtensionInstallRequested(extension_id); |
319 } | 319 } |
(...skipping 26 matching lines...) Expand all Loading... |
346 picker_.Wait(); | 346 picker_.Wait(); |
347 EXPECT_EQ(2, picker_.num_installed_services_); | 347 EXPECT_EQ(2, picker_.num_installed_services_); |
348 EXPECT_EQ(0, picker_.num_icons_changed_); | 348 EXPECT_EQ(0, picker_.num_icons_changed_); |
349 | 349 |
350 webkit_glue::WebIntentData intent; | 350 webkit_glue::WebIntentData intent; |
351 intent.action = ASCIIToUTF16("a"); | 351 intent.action = ASCIIToUTF16("a"); |
352 intent.type = ASCIIToUTF16("b"); | 352 intent.type = ASCIIToUTF16("b"); |
353 IntentsDispatcherMock dispatcher(intent); | 353 IntentsDispatcherMock dispatcher(intent); |
354 controller_->SetIntentsDispatcher(&dispatcher); | 354 controller_->SetIntentsDispatcher(&dispatcher); |
355 | 355 |
356 OnServiceChosen(kServiceURL2, WebIntentPickerModel::DISPOSITION_WINDOW); | 356 OnServiceChosen(kServiceURL2, |
| 357 webkit_glue::WebIntentServiceData::DISPOSITION_WINDOW); |
357 ASSERT_EQ(2, browser()->tab_count()); | 358 ASSERT_EQ(2, browser()->tab_count()); |
358 EXPECT_EQ(GURL(kServiceURL2), | 359 EXPECT_EQ(GURL(kServiceURL2), |
359 chrome::GetActiveWebContents(browser())->GetURL()); | 360 chrome::GetActiveWebContents(browser())->GetURL()); |
360 | 361 |
361 EXPECT_TRUE(GetWindowDispositionTarget( | 362 EXPECT_TRUE(GetWindowDispositionTarget( |
362 chrome::GetActiveTabContents(browser())->web_intent_picker_controller())); | 363 chrome::GetActiveTabContents(browser())->web_intent_picker_controller())); |
363 | 364 |
364 EXPECT_TRUE(dispatcher.dispatched_); | 365 EXPECT_TRUE(dispatcher.dispatched_); |
365 | 366 |
366 OnSendReturnMessage(webkit_glue::WEB_INTENT_REPLY_SUCCESS); | 367 OnSendReturnMessage(webkit_glue::WEB_INTENT_REPLY_SUCCESS); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 controller_->ShowDialog(kAction1, kType1); | 411 controller_->ShowDialog(kAction1, kType1); |
411 picker_.Wait(); | 412 picker_.Wait(); |
412 EXPECT_EQ(1, picker_.num_installed_services_); | 413 EXPECT_EQ(1, picker_.num_installed_services_); |
413 | 414 |
414 webkit_glue::WebIntentData intent; | 415 webkit_glue::WebIntentData intent; |
415 intent.action = ASCIIToUTF16("a"); | 416 intent.action = ASCIIToUTF16("a"); |
416 intent.type = ASCIIToUTF16("b"); | 417 intent.type = ASCIIToUTF16("b"); |
417 IntentsDispatcherMock dispatcher(intent); | 418 IntentsDispatcherMock dispatcher(intent); |
418 controller_->SetIntentsDispatcher(&dispatcher); | 419 controller_->SetIntentsDispatcher(&dispatcher); |
419 | 420 |
420 OnServiceChosen(kServiceURL1, WebIntentPickerModel::DISPOSITION_WINDOW); | 421 OnServiceChosen(kServiceURL1, |
| 422 webkit_glue::WebIntentServiceData::DISPOSITION_WINDOW); |
421 ASSERT_EQ(3, browser()->tab_count()); | 423 ASSERT_EQ(3, browser()->tab_count()); |
422 EXPECT_EQ(GURL(kServiceURL1), | 424 EXPECT_EQ(GURL(kServiceURL1), |
423 chrome::GetActiveWebContents(browser())->GetURL()); | 425 chrome::GetActiveWebContents(browser())->GetURL()); |
424 | 426 |
425 EXPECT_TRUE(dispatcher.dispatched_); | 427 EXPECT_TRUE(dispatcher.dispatched_); |
426 | 428 |
427 OnSendReturnMessage(webkit_glue::WEB_INTENT_REPLY_SUCCESS); | 429 OnSendReturnMessage(webkit_glue::WEB_INTENT_REPLY_SUCCESS); |
428 ASSERT_EQ(2, browser()->tab_count()); | 430 ASSERT_EQ(2, browser()->tab_count()); |
429 EXPECT_EQ(original, chrome::GetActiveWebContents(browser())->GetURL()); | 431 EXPECT_EQ(original, chrome::GetActiveWebContents(browser())->GetURL()); |
430 } | 432 } |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 | 634 |
633 EXPECT_EQ(2, picker_.num_installed_services_); | 635 EXPECT_EQ(2, picker_.num_installed_services_); |
634 | 636 |
635 // The tab is shown immediately without needing to call OnServiceChosen. | 637 // The tab is shown immediately without needing to call OnServiceChosen. |
636 ASSERT_EQ(2, browser()->tab_count()); | 638 ASSERT_EQ(2, browser()->tab_count()); |
637 EXPECT_EQ(GURL(kServiceURL1), | 639 EXPECT_EQ(GURL(kServiceURL1), |
638 chrome::GetActiveWebContents(browser())->GetURL()); | 640 chrome::GetActiveWebContents(browser())->GetURL()); |
639 | 641 |
640 EXPECT_TRUE(dispatcher.dispatched_); | 642 EXPECT_TRUE(dispatcher.dispatched_); |
641 } | 643 } |
OLD | NEW |