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

Unified Diff: components/data_reduction_proxy/content/browser/content_lofi_ui_service_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/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 3ed2f3c449d3f790b56a2e99576044456acc3c08..fff7ddfd7a716d9790a70ea07c32e57d19bdbcce 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
@@ -27,12 +27,12 @@ namespace data_reduction_proxy {
class ContentLoFiUIServiceTest : public content::RenderViewHostTestHarness {
public:
- ContentLoFiUIServiceTest() : callback_called_(false) {
+ ContentLoFiUIServiceTest() : callback_called_(false), is_preview_(false) {
// Cannot use IO_MAIN_LOOP with RenderViewHostTestHarness.
SetThreadBundleOptions(content::TestBrowserThreadBundle::REAL_IO_THREAD);
}
- void RunTestOnIOThread(base::RunLoop* ui_run_loop) {
+ void RunTestOnIOThread(base::RunLoop* ui_run_loop, bool is_preview) {
ASSERT_TRUE(ui_run_loop);
EXPECT_TRUE(
content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
@@ -51,7 +51,7 @@ class ContentLoFiUIServiceTest : public content::RenderViewHostTestHarness {
scoped_ptr<net::URLRequest> request = CreateRequest(context, &delegate);
- content_lofi_ui_service_->OnLoFiReponseReceived(*request);
+ content_lofi_ui_service_->OnLoFiReponseReceived(*request, is_preview);
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
@@ -80,21 +80,25 @@ class ContentLoFiUIServiceTest : public content::RenderViewHostTestHarness {
return request;
}
- void OnLoFiResponseReceivedCallback(content::WebContents* web_contents) {
+ void OnLoFiResponseReceivedCallback(content::WebContents* web_contents,
+ bool is_preview) {
EXPECT_TRUE(
content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
callback_called_ = true;
+ is_preview_ = is_preview;
}
- void VerifyOnLoFiResponseReceivedCallback() {
+ void VerifyOnLoFiResponseReceivedCallback(bool is_preview) {
EXPECT_TRUE(
content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
EXPECT_TRUE(callback_called_);
+ EXPECT_EQ(is_preview, is_preview_);
}
private:
scoped_ptr<ContentLoFiUIService> content_lofi_ui_service_;
bool callback_called_;
+ bool is_preview_;
};
TEST_F(ContentLoFiUIServiceTest, OnLoFiResponseReceived) {
@@ -102,10 +106,21 @@ TEST_F(ContentLoFiUIServiceTest, OnLoFiResponseReceived) {
content::BrowserThread::PostTask(
content::BrowserThread::IO, FROM_HERE,
base::Bind(&ContentLoFiUIServiceTest::RunTestOnIOThread,
- base::Unretained(this), &ui_run_loop));
+ base::Unretained(this), &ui_run_loop, false));
ui_run_loop.Run();
base::MessageLoop::current()->RunUntilIdle();
- VerifyOnLoFiResponseReceivedCallback();
+ VerifyOnLoFiResponseReceivedCallback(false);
+}
+
+TEST_F(ContentLoFiUIServiceTest, OnLoFiPreviewResponseReceived) {
+ base::RunLoop ui_run_loop;
+ content::BrowserThread::PostTask(
+ content::BrowserThread::IO, FROM_HERE,
+ base::Bind(&ContentLoFiUIServiceTest::RunTestOnIOThread,
+ base::Unretained(this), &ui_run_loop, true));
+ ui_run_loop.Run();
+ base::MessageLoop::current()->RunUntilIdle();
+ VerifyOnLoFiResponseReceivedCallback(true);
}
} // namespace data_reduction_proxy

Powered by Google App Engine
This is Rietveld 408576698