| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 #include "content/public/common/content_switches.h" | 40 #include "content/public/common/content_switches.h" |
| 41 #include "content/public/test/browser_test_utils.h" | 41 #include "content/public/test/browser_test_utils.h" |
| 42 #include "content/public/test/test_utils.h" | 42 #include "content/public/test/test_utils.h" |
| 43 #include "crypto/sha2.h" | 43 #include "crypto/sha2.h" |
| 44 #include "net/base/sdch_manager.h" | 44 #include "net/base/sdch_manager.h" |
| 45 #include "net/base/sdch_observer.h" | 45 #include "net/base/sdch_observer.h" |
| 46 #include "net/http/http_response_headers.h" | 46 #include "net/http/http_response_headers.h" |
| 47 #include "net/test/embedded_test_server/embedded_test_server.h" | 47 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 48 #include "net/test/embedded_test_server/http_request.h" | 48 #include "net/test/embedded_test_server/http_request.h" |
| 49 #include "net/test/embedded_test_server/http_response.h" | 49 #include "net/test/embedded_test_server/http_response.h" |
| 50 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" |
| 50 #include "net/url_request/url_fetcher.h" | 51 #include "net/url_request/url_fetcher.h" |
| 51 #include "net/url_request/url_fetcher_delegate.h" | 52 #include "net/url_request/url_fetcher_delegate.h" |
| 52 #include "net/url_request/url_request_context.h" | 53 #include "net/url_request/url_request_context.h" |
| 53 #include "net/url_request/url_request_context_getter.h" | 54 #include "net/url_request/url_request_context_getter.h" |
| 54 #include "sdch/open-vcdiff/src/google/vcencoder.h" | 55 #include "sdch/open-vcdiff/src/google/vcencoder.h" |
| 55 #include "testing/gtest/include/gtest/gtest.h" | 56 #include "testing/gtest/include/gtest/gtest.h" |
| 56 | 57 |
| 57 #if defined(OS_CHROMEOS) | 58 #if defined(OS_CHROMEOS) |
| 58 #include "chromeos/chromeos_switches.h" | 59 #include "chromeos/chromeos_switches.h" |
| 59 #endif | 60 #endif |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 public net::URLFetcherDelegate { | 306 public net::URLFetcherDelegate { |
| 306 public: | 307 public: |
| 307 static const char kTestHost[]; | 308 static const char kTestHost[]; |
| 308 | 309 |
| 309 SdchBrowserTest() : response_handler_(kTestHost) {} | 310 SdchBrowserTest() : response_handler_(kTestHost) {} |
| 310 | 311 |
| 311 // Helper functions for fetching data. | 312 // Helper functions for fetching data. |
| 312 | 313 |
| 313 void FetchUrlDetailed(GURL url, net::URLRequestContextGetter* getter) { | 314 void FetchUrlDetailed(GURL url, net::URLRequestContextGetter* getter) { |
| 314 url_fetch_complete_ = false; | 315 url_fetch_complete_ = false; |
| 315 fetcher_ = net::URLFetcher::Create(url, net::URLFetcher::GET, this); | 316 fetcher_ = net::URLFetcher::Create(url, net::URLFetcher::GET, this, |
| 317 TRAFFIC_ANNOTATION_FOR_TESTS); |
| 316 fetcher_->SetRequestContext(getter); | 318 fetcher_->SetRequestContext(getter); |
| 317 fetcher_->Start(); | 319 fetcher_->Start(); |
| 318 if (!url_fetch_complete_) { | 320 if (!url_fetch_complete_) { |
| 319 waiting_ = true; | 321 waiting_ = true; |
| 320 content::RunMessageLoop(); | 322 content::RunMessageLoop(); |
| 321 waiting_ = false; | 323 waiting_ = false; |
| 322 } | 324 } |
| 323 CHECK(url_fetch_complete_); | 325 CHECK(url_fetch_complete_); |
| 324 } | 326 } |
| 325 | 327 |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 ASSERT_TRUE(SetupIncognitoBrowser()); | 756 ASSERT_TRUE(SetupIncognitoBrowser()); |
| 755 ASSERT_TRUE(ForceSdchDictionaryLoad(incognito_browser())); | 757 ASSERT_TRUE(ForceSdchDictionaryLoad(incognito_browser())); |
| 756 | 758 |
| 757 // Data fetches on main browser should not be SDCH encoded. | 759 // Data fetches on main browser should not be SDCH encoded. |
| 758 bool sdch_encoding_used = true; | 760 bool sdch_encoding_used = true; |
| 759 ASSERT_TRUE(GetData(&sdch_encoding_used)); | 761 ASSERT_TRUE(GetData(&sdch_encoding_used)); |
| 760 EXPECT_FALSE(sdch_encoding_used); | 762 EXPECT_FALSE(sdch_encoding_used); |
| 761 } | 763 } |
| 762 | 764 |
| 763 } // namespace | 765 } // namespace |
| OLD | NEW |