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

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

Issue 1596573002: Remove extra calls of didMeaningfulLayout() during the same navigation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/thread_task_runner_handle.h" 8 #include "base/thread_task_runner_handle.h"
9 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/tabs/tab_strip_model.h" 10 #include "chrome/browser/ui/tabs/tab_strip_model.h"
11 #include "chrome/common/chrome_switches.h" 11 #include "chrome/common/chrome_switches.h"
12 #include "chrome/test/base/in_process_browser_test.h" 12 #include "chrome/test/base/in_process_browser_test.h"
13 #include "chrome/test/base/ui_test_utils.h" 13 #include "chrome/test/base/ui_test_utils.h"
14 #include "components/dom_distiller/content/browser/distillable_page_utils.h" 14 #include "components/dom_distiller/content/browser/distillable_page_utils.h"
15 #include "components/dom_distiller/core/dom_distiller_switches.h" 15 #include "components/dom_distiller/core/dom_distiller_switches.h"
16 #include "content/public/test/browser_test_utils.h" 16 #include "content/public/test/browser_test_utils.h"
17 #include "content/public/test/test_utils.h" 17 #include "content/public/test/test_utils.h"
18 #include "net/test/embedded_test_server/embedded_test_server.h" 18 #include "net/test/embedded_test_server/embedded_test_server.h"
19 #include "testing/gmock/include/gmock/gmock.h" 19 #include "testing/gmock/include/gmock/gmock.h"
20 20
21 namespace dom_distiller { 21 namespace dom_distiller {
22 22
23 using ::testing::_; 23 using ::testing::_;
24 using namespace switches::reader_mode_heuristics; 24 using namespace switches::reader_mode_heuristics;
25 25
26 namespace { 26 namespace {
27 27
28 const char kSimpleArticlePath[] = "/dom_distiller/simple_article.html"; 28 const char kSimpleArticlePath[] = "/dom_distiller/simple_article.html";
29 const char kSimpleArticleIFramePath[] =
30 "/dom_distiller/simple_article_iframe.html";
29 const char kArticlePath[] = "/dom_distiller/og_article.html"; 31 const char kArticlePath[] = "/dom_distiller/og_article.html";
30 const char kNonArticlePath[] = "/dom_distiller/non_og_article.html"; 32 const char kNonArticlePath[] = "/dom_distiller/non_og_article.html";
31 33
34 const char* kAllPaths[] = {
dglazkov 2016/01/15 19:41:47 We need to test this at a higher level, since the
wychen 2016/01/15 22:31:02 I'll add one in WebViewTest. I think it would stil
35 kSimpleArticlePath,
36 kSimpleArticleIFramePath,
37 kArticlePath,
38 kNonArticlePath
39 };
40
32 class Holder { 41 class Holder {
33 public: 42 public:
34 virtual ~Holder() {} 43 virtual ~Holder() {}
35 virtual void OnResult(bool, bool) = 0; 44 virtual void OnResult(bool, bool) = 0;
36 }; 45 };
37 46
38 class MockDelegate : public Holder { 47 class MockDelegate : public Holder {
39 public: 48 public:
40 MOCK_METHOD2(OnResult, void(bool, bool)); 49 MOCK_METHOD2(OnResult, void(bool, bool));
41 50
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 DistillablePageUtilsBrowserTestOption<kAlwaysTrue>; 98 DistillablePageUtilsBrowserTestOption<kAlwaysTrue>;
90 99
91 IN_PROC_BROWSER_TEST_F(DistillablePageUtilsBrowserTestAlways, 100 IN_PROC_BROWSER_TEST_F(DistillablePageUtilsBrowserTestAlways,
92 TestDelegate) { 101 TestDelegate) {
93 // Run twice to make sure the delegate object is still alive. 102 // Run twice to make sure the delegate object is still alive.
94 for (int i = 0; i < 2; ++i) { 103 for (int i = 0; i < 2; ++i) {
95 testing::InSequence dummy; 104 testing::InSequence dummy;
96 EXPECT_CALL(holder_, OnResult(true, true)).Times(1); 105 EXPECT_CALL(holder_, OnResult(true, true)).Times(1);
97 NavigateAndWait(kSimpleArticlePath); 106 NavigateAndWait(kSimpleArticlePath);
98 } 107 }
108 for (unsigned i = 0; i < sizeof(kAllPaths) / sizeof(kAllPaths[0]); ++i) {
109 testing::InSequence dummy;
110 EXPECT_CALL(holder_, OnResult(true, true)).Times(1);
111 NavigateAndWait(kAllPaths[i]);
112 }
99 // Test pages that we don't care about its distillability. 113 // Test pages that we don't care about its distillability.
100 { 114 {
101 testing::InSequence dummy; 115 testing::InSequence dummy;
102 EXPECT_CALL(holder_, OnResult(_, _)).Times(0); 116 EXPECT_CALL(holder_, OnResult(_, _)).Times(0);
103 NavigateAndWait("about:blank"); 117 NavigateAndWait("about:blank");
104 } 118 }
105 } 119 }
106 120
107 121
108 using DistillablePageUtilsBrowserTestNone = 122 using DistillablePageUtilsBrowserTestNone =
(...skipping 22 matching lines...) Expand all
131 NavigateAndWait(kNonArticlePath); 145 NavigateAndWait(kNonArticlePath);
132 } 146 }
133 } 147 }
134 148
135 149
136 using DistillablePageUtilsBrowserTestAdaboost = 150 using DistillablePageUtilsBrowserTestAdaboost =
137 DistillablePageUtilsBrowserTestOption<kAdaBoost>; 151 DistillablePageUtilsBrowserTestOption<kAdaBoost>;
138 152
139 IN_PROC_BROWSER_TEST_F(DistillablePageUtilsBrowserTestAdaboost, 153 IN_PROC_BROWSER_TEST_F(DistillablePageUtilsBrowserTestAdaboost,
140 TestDelegate) { 154 TestDelegate) {
141 { 155 const char* paths[] = {kSimpleArticlePath, kSimpleArticleIFramePath};
156 for (unsigned i = 0; i < sizeof(paths)/sizeof(paths[0]); ++i) {
142 testing::InSequence dummy; 157 testing::InSequence dummy;
143 EXPECT_CALL(holder_, OnResult(true, false)).Times(1); 158 EXPECT_CALL(holder_, OnResult(true, false)).Times(1);
144 EXPECT_CALL(holder_, OnResult(true, true)).Times(1); 159 EXPECT_CALL(holder_, OnResult(true, true)).Times(1);
145 NavigateAndWait(kSimpleArticlePath); 160 NavigateAndWait(paths[i]);
146 } 161 }
147 { 162 {
148 testing::InSequence dummy; 163 testing::InSequence dummy;
149 EXPECT_CALL(holder_, OnResult(false, false)).Times(1); 164 EXPECT_CALL(holder_, OnResult(false, false)).Times(1);
150 EXPECT_CALL(holder_, OnResult(false, true)).Times(1); 165 EXPECT_CALL(holder_, OnResult(false, true)).Times(1);
151 NavigateAndWait(kNonArticlePath); 166 NavigateAndWait(kNonArticlePath);
152 } 167 }
153 } 168 }
154 169
155 } // namespace dom_distiller 170 } // namespace dom_distiller
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698