| Index: chrome/browser/dom_distiller/dom_distiller_viewer_source_browsertest.cc
|
| diff --git a/chrome/browser/dom_distiller/dom_distiller_viewer_source_browsertest.cc b/chrome/browser/dom_distiller/dom_distiller_viewer_source_browsertest.cc
|
| index d36e45b76a75a292ac8f04a5af01ae72cda98819..4640bc93d2c4bd9ff5ed35cf239118d8fcb816b3 100644
|
| --- a/chrome/browser/dom_distiller/dom_distiller_viewer_source_browsertest.cc
|
| +++ b/chrome/browser/dom_distiller/dom_distiller_viewer_source_browsertest.cc
|
| @@ -18,6 +18,7 @@
|
| #include "chrome/test/base/ui_test_utils.h"
|
| #include "components/dom_distiller/content/dom_distiller_viewer_source.h"
|
| #include "components/dom_distiller/core/article_entry.h"
|
| +#include "components/dom_distiller/core/distilled_page_prefs.h"
|
| #include "components/dom_distiller/core/distiller.h"
|
| #include "components/dom_distiller/core/dom_distiller_service.h"
|
| #include "components/dom_distiller/core/dom_distiller_store.h"
|
| @@ -57,6 +58,10 @@ const char kGetContent[] =
|
| "window.domAutomationController.send("
|
| "document.getElementById('content').innerHTML)";
|
|
|
| +const char kGetBodyClass[] =
|
| + "window.domAutomationController.send("
|
| + "document.body.className)";
|
| +
|
| void AddEntry(const ArticleEntry& e, FakeDB<ArticleEntry>::EntryMap* map) {
|
| (*map)[e.entry_id()] = e;
|
| }
|
| @@ -99,7 +104,11 @@ class DomDistillerViewerSourceBrowserTest : public InProcessBrowserTest {
|
| CreateStoreWithFakeDB(fake_db,
|
| FakeDB<ArticleEntry>::EntryMap())),
|
| scoped_ptr<DistillerFactory>(distiller_factory_),
|
| - scoped_ptr<DistillerPageFactory>(distiller_page_factory_));
|
| + scoped_ptr<DistillerPageFactory>(distiller_page_factory_),
|
| + scoped_ptr<DistilledPagePrefs>(
|
| + new DistilledPagePrefs(
|
| + Profile::FromBrowserContext(
|
| + context)->GetPrefs())));
|
| fake_db->InitCallback(true);
|
| fake_db->LoadCallback(true);
|
| if (expect_distillation_) {
|
| @@ -321,4 +330,31 @@ IN_PROC_BROWSER_TEST_F(DomDistillerViewerSourceBrowserTest,
|
| EXPECT_THAT(result, HasSubstr("Page 2 content"));
|
| }
|
|
|
| +IN_PROC_BROWSER_TEST_F(DomDistillerViewerSourceBrowserTest, PrefChange) {
|
| + expect_distillation_ = true;
|
| + expect_distiller_page_ = true;
|
| + GURL view_url("http://www.example.com/1");
|
| + content::WebContents* contents =
|
| + browser()->tab_strip_model()->GetActiveWebContents();
|
| + const GURL url = url_utils::GetDistillerViewUrlFromUrl(
|
| + chrome::kDomDistillerScheme, view_url);
|
| + ViewSingleDistilledPage(url, "text/html");
|
| + content::WaitForLoadStop(contents);
|
| + std::string result;
|
| + EXPECT_TRUE(content::ExecuteScriptAndExtractString(
|
| + contents, kGetBodyClass, &result));
|
| + EXPECT_EQ("light", result);
|
| +
|
| + // Getting DistilledPagePrefs instance.
|
| + DistilledPagePrefs* distilled_page_prefs =
|
| + DomDistillerServiceFactory::GetForBrowserContext(
|
| + browser()->profile())->GetDistilledPagePrefs();
|
| +
|
| + distilled_page_prefs->SetTheme(DistilledPagePrefs::DARK);
|
| + base::RunLoop().RunUntilIdle();
|
| + EXPECT_TRUE(content::ExecuteScriptAndExtractString(
|
| + contents, kGetBodyClass, &result));
|
| + EXPECT_EQ("dark", result);
|
| +}
|
| +
|
| } // namespace dom_distiller
|
|
|