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