| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // End-to-end SDCH tests. Uses the embedded test server to return SDCH | 5 // End-to-end SDCH tests. Uses the embedded test server to return SDCH |
| 6 // results | 6 // results |
| 7 | 7 |
| 8 #include "base/base64.h" | 8 #include "base/base64.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 #if defined(OS_CHROMEOS) | 592 #if defined(OS_CHROMEOS) |
| 593 command_line->AppendSwitch( | 593 command_line->AppendSwitch( |
| 594 chromeos::switches::kIgnoreUserProfileMappingForTests); | 594 chromeos::switches::kIgnoreUserProfileMappingForTests); |
| 595 #endif | 595 #endif |
| 596 } | 596 } |
| 597 | 597 |
| 598 void SetUpOnMainThread() override { | 598 void SetUpOnMainThread() override { |
| 599 test_server_.RegisterRequestHandler( | 599 test_server_.RegisterRequestHandler( |
| 600 base::Bind(&SdchResponseHandler::HandleRequest, | 600 base::Bind(&SdchResponseHandler::HandleRequest, |
| 601 base::Unretained(&response_handler_))); | 601 base::Unretained(&response_handler_))); |
| 602 CHECK(test_server_.InitializeAndWaitUntilReady()); | 602 CHECK(test_server_.Start()); |
| 603 url_request_context_getter_ = browser()->profile()->GetRequestContext(); | 603 url_request_context_getter_ = browser()->profile()->GetRequestContext(); |
| 604 | 604 |
| 605 content::BrowserThread::PostTask( | 605 content::BrowserThread::PostTask( |
| 606 content::BrowserThread::IO, | 606 content::BrowserThread::IO, |
| 607 FROM_HERE, | 607 FROM_HERE, |
| 608 base::Bind(&SdchBrowserTest::SubscribeToSdchNotifications, | 608 base::Bind(&SdchBrowserTest::SubscribeToSdchNotifications, |
| 609 base::Unretained(this), | 609 base::Unretained(this), |
| 610 url_request_context_getter_)); | 610 url_request_context_getter_)); |
| 611 } | 611 } |
| 612 | 612 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 637 } | 637 } |
| 638 | 638 |
| 639 // URLFetcherDelegate | 639 // URLFetcherDelegate |
| 640 void OnURLFetchComplete(const net::URLFetcher* source) override { | 640 void OnURLFetchComplete(const net::URLFetcher* source) override { |
| 641 url_fetch_complete_ = true; | 641 url_fetch_complete_ = true; |
| 642 if (waiting_) | 642 if (waiting_) |
| 643 base::MessageLoopForUI::current()->QuitWhenIdle(); | 643 base::MessageLoopForUI::current()->QuitWhenIdle(); |
| 644 } | 644 } |
| 645 | 645 |
| 646 SdchResponseHandler response_handler_; | 646 SdchResponseHandler response_handler_; |
| 647 net::test_server::EmbeddedTestServer test_server_; | 647 net::EmbeddedTestServer test_server_; |
| 648 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; | 648 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; |
| 649 scoped_ptr<net::URLFetcher> fetcher_; | 649 scoped_ptr<net::URLFetcher> fetcher_; |
| 650 bool url_fetch_complete_; | 650 bool url_fetch_complete_; |
| 651 bool waiting_; | 651 bool waiting_; |
| 652 base::ScopedTempDir second_profile_data_dir_; | 652 base::ScopedTempDir second_profile_data_dir_; |
| 653 Profile* second_profile_; | 653 Profile* second_profile_; |
| 654 Browser* second_browser_; | 654 Browser* second_browser_; |
| 655 Browser* incognito_browser_; | 655 Browser* incognito_browser_; |
| 656 | 656 |
| 657 // IO Thread access only. | 657 // IO Thread access only. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 ASSERT_TRUE(SetupIncognitoBrowser()); | 706 ASSERT_TRUE(SetupIncognitoBrowser()); |
| 707 ASSERT_TRUE(ForceSdchDictionaryLoad(incognito_browser())); | 707 ASSERT_TRUE(ForceSdchDictionaryLoad(incognito_browser())); |
| 708 | 708 |
| 709 // Data fetches on main browser should not be SDCH encoded. | 709 // Data fetches on main browser should not be SDCH encoded. |
| 710 bool sdch_encoding_used = true; | 710 bool sdch_encoding_used = true; |
| 711 ASSERT_TRUE(GetData(&sdch_encoding_used)); | 711 ASSERT_TRUE(GetData(&sdch_encoding_used)); |
| 712 EXPECT_FALSE(sdch_encoding_used); | 712 EXPECT_FALSE(sdch_encoding_used); |
| 713 } | 713 } |
| 714 | 714 |
| 715 } // namespace | 715 } // namespace |
| OLD | NEW |