Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(831)

Unified Diff: components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc

Issue 1576493002: Change the Lo-Fi snackbar strings for Lo-Fi preview pages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@showLoFiSnackbarNative
Patch Set: newt comments Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc
index 20d9861cc0d6ad8fd556a1ac40fa6ac1df26549f..872c49d7faac9cd1e51d1fb4db29f69bccdbd075 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc
@@ -113,17 +113,21 @@ class TestLoFiDecider : public LoFiDecider {
class TestLoFiUIService : public LoFiUIService {
public:
- TestLoFiUIService() : on_lofi_response_(false) {}
+ TestLoFiUIService() : on_lofi_response_(false), is_preview_(false) {}
~TestLoFiUIService() override {}
bool DidNotifyLoFiResponse() const { return on_lofi_response_; }
+ bool is_preview() const { return is_preview_; }
- void OnLoFiReponseReceived(const net::URLRequest& request) override {
+ void OnLoFiReponseReceived(const net::URLRequest& request,
+ bool is_preview) override {
on_lofi_response_ = true;
+ is_preview_ = is_preview;
}
private:
bool on_lofi_response_;
+ bool is_preview_;
};
} // namespace
@@ -188,6 +192,10 @@ class DataReductionProxyNetworkDelegateTest : public testing::Test {
EXPECT_EQ(lofi_response, lofi_ui_service_->DidNotifyLoFiResponse());
}
+ void VerifyLoFiPreviewResponse(bool is_preview) {
+ EXPECT_EQ(is_preview, lofi_ui_service_->is_preview());
+ }
+
int64_t total_received_bytes() {
return data_reduction_proxy_network_delegate_->total_received_bytes_;
}
@@ -740,4 +748,41 @@ TEST_F(DataReductionProxyNetworkDelegateTest, OnCompletedInternalLoFi) {
}
}
+TEST_F(DataReductionProxyNetworkDelegateTest, OnCompletedInternalLoFiPreview) {
+ const int64_t kResponseContentLength = 140;
+ const int64_t kOriginalContentLength = 200;
+
+ set_network_delegate(data_reduction_proxy_network_delegate_.get());
+
+ // Enable Lo-Fi.
+ const struct {
+ bool is_preview;
+ } tests[] = {
+ {false}, {true},
+ };
+
+ for (size_t i = 0; i < arraysize(tests); ++i) {
+ std::string raw_headers =
+ "HTTP/1.1 200 OK\n"
+ "Date: Wed, 28 Nov 2007 09:40:09 GMT\n"
+ "Expires: Mon, 24 Nov 2014 12:45:26 GMT\n"
+ "Via: 1.1 Chrome-Compression-Proxy\n"
+ "x-original-content-length: " +
+ base::Int64ToString(kOriginalContentLength) + "\n";
+
+ if (tests[i].is_preview)
+ raw_headers += "Chrome-Proxy: q=preview\n";
+
+ HeadersToRaw(&raw_headers);
+ std::string response_headers =
+ net::HttpUtil::ConvertHeadersBackToHTTPResponse(raw_headers);
+
+ FetchURLRequest(GURL("http://www.google.com/"), response_headers,
+ kResponseContentLength);
+
+ VerifyDidNotifyLoFiResponse(tests[i].is_preview);
+ VerifyLoFiPreviewResponse(tests[i].is_preview);
+ }
+}
+
} // namespace data_reduction_proxy

Powered by Google App Engine
This is Rietveld 408576698