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

Side by Side Diff: chrome/browser/dom_distiller/dom_distiller_viewer_source_browsertest.cc

Issue 1130703003: Show template before distiller finishes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ios-superclass
Patch Set: Fix flaky test Created 5 years, 6 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 unified diff | Download patch
« no previous file with comments | « build/ios/grit_whitelist.txt ('k') | chrome/browser/dom_distiller/tab_utils_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include <string.h> 5 #include <string.h>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/guid.h" 8 #include "base/guid.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" 10 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h"
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 IN_PROC_BROWSER_TEST_F(DomDistillerViewerSourceBrowserTest, 250 IN_PROC_BROWSER_TEST_F(DomDistillerViewerSourceBrowserTest,
251 InvalidURLShouldNotCrash) { 251 InvalidURLShouldNotCrash) {
252 // This is a bogus URL, so no distillation will happen. 252 // This is a bogus URL, so no distillation will happen.
253 expect_distillation_ = false; 253 expect_distillation_ = false;
254 expect_distiller_page_ = false; 254 expect_distiller_page_ = false;
255 const GURL url(std::string(kDomDistillerScheme) + "://bogus/foobar"); 255 const GURL url(std::string(kDomDistillerScheme) + "://bogus/foobar");
256 ViewSingleDistilledPage(url, "text/html"); 256 ViewSingleDistilledPage(url, "text/html");
257 } 257 }
258 258
259 IN_PROC_BROWSER_TEST_F(DomDistillerViewerSourceBrowserTest, 259 IN_PROC_BROWSER_TEST_F(DomDistillerViewerSourceBrowserTest,
260 EarlyTemplateLoad) {
261 dom_distiller::DomDistillerServiceFactory::GetInstance()
262 ->SetTestingFactoryAndUse(browser()->profile(), &Build);
263
264 scoped_refptr<content::MessageLoopRunner> distillation_done_runner =
265 new content::MessageLoopRunner;
266
267 FakeDistiller* distiller = new FakeDistiller(
268 false,
269 distillation_done_runner->QuitClosure());
270 EXPECT_CALL(*distiller_factory_, CreateDistillerImpl())
271 .WillOnce(testing::Return(distiller));
272
273 // Navigate to a URL.
274 GURL url(dom_distiller::url_utils::GetDistillerViewUrlFromUrl(
275 kDomDistillerScheme, GURL("http://urlthatlooksvalid.com")));
276 chrome::NavigateParams params(browser(), url, ui::PAGE_TRANSITION_TYPED);
277 chrome::Navigate(&params);
278 distillation_done_runner->Run();
279
280 content::WebContents* contents =
281 browser()->tab_strip_model()->GetActiveWebContents();
282
283 // Wait for the page load to complete (should only be template).
284 content::WaitForLoadStop(contents);
285 std::string result;
286 // Loading spinner should be on screen at this point.
287 EXPECT_TRUE(content::ExecuteScriptAndExtractString(
288 contents, kGetLoadIndicatorClassName , &result));
289 EXPECT_EQ("visible", result);
290
291 EXPECT_TRUE(content::ExecuteScriptAndExtractString(
292 contents, kGetContent , &result));
293 EXPECT_THAT(result, Not(HasSubstr("content")));
294
295 // Finish distillation and make sure the spinner has been replaced by text.
296 std::vector<scoped_refptr<ArticleDistillationUpdate::RefCountedPageProto> >
297 update_pages;
298 scoped_ptr<DistilledArticleProto> article(new DistilledArticleProto());
299
300 scoped_refptr<base::RefCountedData<DistilledPageProto> > page_proto =
301 new base::RefCountedData<DistilledPageProto>();
302 page_proto->data.set_url("http://foo.html");
303 page_proto->data.set_html("<div>content</div>");
304 update_pages.push_back(page_proto);
305 *(article->add_pages()) = page_proto->data;
306
307 ArticleDistillationUpdate update(update_pages, true, false);
308 distiller->RunDistillerUpdateCallback(update);
309
310 content::WaitForLoadStop(contents);
311
312 EXPECT_TRUE(content::ExecuteScriptAndExtractString(
313 contents, kGetContent , &result));
314 EXPECT_THAT(result, HasSubstr("content"));
315 }
316
317 IN_PROC_BROWSER_TEST_F(DomDistillerViewerSourceBrowserTest,
260 MultiPageArticle) { 318 MultiPageArticle) {
261 expect_distillation_ = false; 319 expect_distillation_ = false;
262 expect_distiller_page_ = true; 320 expect_distiller_page_ = true;
263 dom_distiller::DomDistillerServiceFactory::GetInstance() 321 dom_distiller::DomDistillerServiceFactory::GetInstance()
264 ->SetTestingFactoryAndUse(browser()->profile(), &Build); 322 ->SetTestingFactoryAndUse(browser()->profile(), &Build);
265 323
266 scoped_refptr<content::MessageLoopRunner> distillation_done_runner = 324 scoped_refptr<content::MessageLoopRunner> distillation_done_runner =
267 new content::MessageLoopRunner; 325 new content::MessageLoopRunner;
268 326
269 FakeDistiller* distiller = new FakeDistiller( 327 FakeDistiller* distiller = new FakeDistiller(
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 EXPECT_EQ("dark sans-serif", result); 437 EXPECT_EQ("dark sans-serif", result);
380 438
381 distilled_page_prefs->SetFontFamily(DistilledPagePrefs::SERIF); 439 distilled_page_prefs->SetFontFamily(DistilledPagePrefs::SERIF);
382 base::RunLoop().RunUntilIdle(); 440 base::RunLoop().RunUntilIdle();
383 EXPECT_TRUE( 441 EXPECT_TRUE(
384 content::ExecuteScriptAndExtractString(contents, kGetBodyClass, &result)); 442 content::ExecuteScriptAndExtractString(contents, kGetBodyClass, &result));
385 EXPECT_EQ("dark serif", result); 443 EXPECT_EQ("dark serif", result);
386 } 444 }
387 445
388 } // namespace dom_distiller 446 } // namespace dom_distiller
OLDNEW
« no previous file with comments | « build/ios/grit_whitelist.txt ('k') | chrome/browser/dom_distiller/tab_utils_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698