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

Unified Diff: components/data_reduction_proxy/content/browser/content_lofi_ui_service_unittest.cc

Issue 2848293002: Adding the Previews infobar to pages that show a client LoFi image (Closed)
Patch Set: sclittle comments Created 3 years, 8 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/content/browser/content_lofi_ui_service_unittest.cc
diff --git a/components/data_reduction_proxy/content/browser/content_lofi_ui_service_unittest.cc b/components/data_reduction_proxy/content/browser/content_lofi_ui_service_unittest.cc
index 52d6503347e0c7afba1d5ff683b604cf3498df4a..845b08200f0cf23b456f89ffefecd292170e20df 100644
--- a/components/data_reduction_proxy/content/browser/content_lofi_ui_service_unittest.cc
+++ b/components/data_reduction_proxy/content/browser/content_lofi_ui_service_unittest.cc
@@ -34,7 +34,7 @@ class ContentLoFiUIServiceTest : public content::RenderViewHostTestHarness {
SetThreadBundleOptions(content::TestBrowserThreadBundle::REAL_IO_THREAD);
}
- void RunTestOnIOThread(base::RunLoop* ui_run_loop) {
+ void RunTestOnIOThread(base::RunLoop* ui_run_loop, bool is_server_lofi) {
ASSERT_TRUE(ui_run_loop);
EXPECT_TRUE(
content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
@@ -54,7 +54,7 @@ class ContentLoFiUIServiceTest : public content::RenderViewHostTestHarness {
std::unique_ptr<net::URLRequest> request =
CreateRequest(context, &delegate);
- content_lofi_ui_service_->OnLoFiReponseReceived(*request);
+ content_lofi_ui_service_->OnLoFiReponseReceived(*request, is_server_lofi);
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
@@ -83,32 +83,49 @@ class ContentLoFiUIServiceTest : public content::RenderViewHostTestHarness {
return request;
}
- void OnLoFiResponseReceivedCallback(content::WebContents* web_contents) {
+ void OnLoFiResponseReceivedCallback(content::WebContents* web_contents,
+ bool is_server_lofi) {
EXPECT_TRUE(
content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
callback_called_ = true;
+ is_server_lofi_ = is_server_lofi;
}
- void VerifyOnLoFiResponseReceivedCallback() {
+ void VerifyOnLoFiResponseReceivedCallback(bool is_server_lofi) {
sclittle 2017/05/03 22:51:29 nit: could this |is_server_lofi| argument here be
RyanSturm 2017/05/03 23:20:30 Done.
EXPECT_TRUE(
content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
EXPECT_TRUE(callback_called_);
+ EXPECT_EQ(is_server_lofi, is_server_lofi_);
}
private:
std::unique_ptr<ContentLoFiUIService> content_lofi_ui_service_;
bool callback_called_;
+ bool is_server_lofi_;
};
-TEST_F(ContentLoFiUIServiceTest, OnLoFiResponseReceived) {
+TEST_F(ContentLoFiUIServiceTest, OnLoFiResponseReceivedServer) {
base::RunLoop ui_run_loop;
+ bool is_server_lofi = true;
content::BrowserThread::PostTask(
content::BrowserThread::IO, FROM_HERE,
base::Bind(&ContentLoFiUIServiceTest::RunTestOnIOThread,
- base::Unretained(this), &ui_run_loop));
+ base::Unretained(this), &ui_run_loop, is_server_lofi));
ui_run_loop.Run();
base::RunLoop().RunUntilIdle();
- VerifyOnLoFiResponseReceivedCallback();
+ VerifyOnLoFiResponseReceivedCallback(is_server_lofi);
+}
+
+TEST_F(ContentLoFiUIServiceTest, OnLoFiResponseReceivedClient) {
+ base::RunLoop ui_run_loop;
+ bool is_server_lofi = false;
+ content::BrowserThread::PostTask(
+ content::BrowserThread::IO, FROM_HERE,
+ base::Bind(&ContentLoFiUIServiceTest::RunTestOnIOThread,
+ base::Unretained(this), &ui_run_loop, is_server_lofi));
+ ui_run_loop.Run();
+ base::RunLoop().RunUntilIdle();
+ VerifyOnLoFiResponseReceivedCallback(is_server_lofi);
}
} // namespace data_reduction_proxy

Powered by Google App Engine
This is Rietveld 408576698