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

Side by Side Diff: blimp/engine/browser_tests/engine_browsertest.cc

Issue 2295543002: More Blimp browser tests for navigation (Closed)
Patch Set: review changes Created 4 years, 3 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 | « no previous file | blimp/engine/session/tab.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "base/memory/ptr_util.h" 5 #include "base/memory/ptr_util.h"
6 #include "blimp/client/core/contents/ime_feature.h" 6 #include "blimp/client/core/contents/ime_feature.h"
7 #include "blimp/client/core/contents/mock_ime_feature_delegate.h" 7 #include "blimp/client/core/contents/mock_ime_feature_delegate.h"
8 #include "blimp/client/core/contents/mock_navigation_feature_delegate.h" 8 #include "blimp/client/core/contents/mock_navigation_feature_delegate.h"
9 #include "blimp/client/core/contents/navigation_feature.h" 9 #include "blimp/client/core/contents/navigation_feature.h"
10 #include "blimp/client/core/contents/tab_control_feature.h" 10 #include "blimp/client/core/contents/tab_control_feature.h"
(...skipping 10 matching lines...) Expand all
21 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
22 #include "ui/gfx/geometry/size.h" 22 #include "ui/gfx/geometry/size.h"
23 #include "url/gurl.h" 23 #include "url/gurl.h"
24 24
25 using ::testing::InvokeWithoutArgs; 25 using ::testing::InvokeWithoutArgs;
26 26
27 namespace blimp { 27 namespace blimp {
28 namespace { 28 namespace {
29 29
30 const int kDummyTabId = 0; 30 const int kDummyTabId = 0;
31 const char kPage1Path[] = "/page1.html";
32 const char kPage2Path[] = "/page2.html";
33 const char kPage1Title[] = "page1";
34 const char kPage2Title[] = "page2";
31 35
32 // Uses a headless client session to test a full engine. 36 // Uses a headless client session to test a full engine.
33 class EngineBrowserTest : public BlimpBrowserTest { 37 class EngineBrowserTest : public BlimpBrowserTest {
34 public: 38 public:
35 EngineBrowserTest() {} 39 EngineBrowserTest() {}
36 40
37 protected: 41 protected:
38 void SetUpOnMainThread() override { 42 void SetUpOnMainThread() override {
39 BlimpBrowserTest::SetUpOnMainThread(); 43 BlimpBrowserTest::SetUpOnMainThread();
40 44
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 // so allow more than one. 88 // so allow more than one.
85 EXPECT_CALL(client_nav_feature_delegate_, 89 EXPECT_CALL(client_nav_feature_delegate_,
86 OnLoadingChanged(kDummyTabId, true)) 90 OnLoadingChanged(kDummyTabId, true))
87 .Times(testing::AtLeast(1)); 91 .Times(testing::AtLeast(1));
88 EXPECT_CALL(client_nav_feature_delegate_, 92 EXPECT_CALL(client_nav_feature_delegate_,
89 OnLoadingChanged(kDummyTabId, false)) 93 OnLoadingChanged(kDummyTabId, false))
90 .WillOnce( 94 .WillOnce(
91 InvokeWithoutArgs(this, &EngineBrowserTest::SignalCompletion)); 95 InvokeWithoutArgs(this, &EngineBrowserTest::SignalCompletion));
92 } 96 }
93 97
98 // Expect that the page load status won't change.
99 void ExpectNoPageLoad() {
Kevin M 2016/08/30 00:52:39 Never called?
Brian Goldman 2016/08/30 01:01:32 Oh whoops, this was a helper than turned out to be
100 EXPECT_CALL(client_nav_feature_delegate_,
101 OnLoadingChanged(kDummyTabId, testing::_))
102 .Times(0);
103 }
104
94 void RunAndVerify() { 105 void RunAndVerify() {
95 RunUntilCompletion(); 106 RunUntilCompletion();
96 testing::Mock::VerifyAndClearExpectations(&client_rw_feature_delegate_); 107 testing::Mock::VerifyAndClearExpectations(&client_rw_feature_delegate_);
97 testing::Mock::VerifyAndClearExpectations(&client_nav_feature_delegate_); 108 testing::Mock::VerifyAndClearExpectations(&client_nav_feature_delegate_);
98 } 109 }
99 110
100 client::MockNavigationFeatureDelegate client_nav_feature_delegate_; 111 client::MockNavigationFeatureDelegate client_nav_feature_delegate_;
101 client::MockRenderWidgetFeatureDelegate client_rw_feature_delegate_; 112 client::MockRenderWidgetFeatureDelegate client_rw_feature_delegate_;
102 client::MockImeFeatureDelegate client_ime_feature_delegate_; 113 client::MockImeFeatureDelegate client_ime_feature_delegate_;
103 std::unique_ptr<client::TestClientSession> client_session_; 114 std::unique_ptr<client::TestClientSession> client_session_;
104 std::string last_page_title_; 115 std::string last_page_title_;
105 116
106 private: 117 private:
107 DISALLOW_COPY_AND_ASSIGN(EngineBrowserTest); 118 DISALLOW_COPY_AND_ASSIGN(EngineBrowserTest);
108 }; 119 };
109 120
110 IN_PROC_BROWSER_TEST_F(EngineBrowserTest, LoadUrl) { 121 IN_PROC_BROWSER_TEST_F(EngineBrowserTest, LoadUrl) {
111 EXPECT_CALL(client_rw_feature_delegate_, OnRenderWidgetCreated(1)); 122 EXPECT_CALL(client_rw_feature_delegate_, OnRenderWidgetCreated(1));
112 ExpectPageLoad(); 123 ExpectPageLoad();
113 NavigateToLocalUrl("/page1.html"); 124 NavigateToLocalUrl(kPage1Path);
114 RunAndVerify(); 125 RunAndVerify();
115 EXPECT_EQ("page1", last_page_title_); 126 EXPECT_EQ(kPage1Title, last_page_title_);
116 } 127 }
117 128
118 IN_PROC_BROWSER_TEST_F(EngineBrowserTest, GoBack) { 129 IN_PROC_BROWSER_TEST_F(EngineBrowserTest, Reload) {
119 ExpectPageLoad(); 130 ExpectPageLoad();
120 NavigateToLocalUrl("/page1.html"); 131 NavigateToLocalUrl(kPage1Path);
121 RunAndVerify(); 132 RunAndVerify();
122 EXPECT_EQ("page1", last_page_title_); 133 EXPECT_EQ(kPage1Title, last_page_title_);
123 134
124 ExpectPageLoad(); 135 ExpectPageLoad();
125 NavigateToLocalUrl("/page2.html"); 136 client_session_->GetNavigationFeature()->Reload(kDummyTabId);
126 RunAndVerify(); 137 RunAndVerify();
127 EXPECT_EQ("page2", last_page_title_); 138 EXPECT_EQ(kPage1Title, last_page_title_);
139 }
140
141 IN_PROC_BROWSER_TEST_F(EngineBrowserTest, GoBackAndGoForward) {
142 ExpectPageLoad();
143 NavigateToLocalUrl(kPage1Path);
144 RunAndVerify();
145 EXPECT_EQ(kPage1Title, last_page_title_);
146
147 ExpectPageLoad();
148 NavigateToLocalUrl(kPage2Path);
149 RunAndVerify();
150 EXPECT_EQ(kPage2Title, last_page_title_);
128 151
129 ExpectPageLoad(); 152 ExpectPageLoad();
130 client_session_->GetNavigationFeature()->GoBack(kDummyTabId); 153 client_session_->GetNavigationFeature()->GoBack(kDummyTabId);
131 RunAndVerify(); 154 RunAndVerify();
132 EXPECT_EQ("page1", last_page_title_); 155 EXPECT_EQ(kPage1Title, last_page_title_);
156
157 ExpectPageLoad();
158 client_session_->GetNavigationFeature()->GoForward(kDummyTabId);
159 RunAndVerify();
160 EXPECT_EQ(kPage2Title, last_page_title_);
161 }
162
163 IN_PROC_BROWSER_TEST_F(EngineBrowserTest, InvalidGoBack) {
164 // Try an invalid GoBack before loading a page, and assert that the page still
165 // loads correctly.
166 ExpectPageLoad();
167 client_session_->GetNavigationFeature()->GoBack(kDummyTabId);
168 NavigateToLocalUrl(kPage1Path);
169 RunAndVerify();
170 EXPECT_EQ(kPage1Title, last_page_title_);
171 }
172
173 IN_PROC_BROWSER_TEST_F(EngineBrowserTest, InvalidGoForward) {
174 ExpectPageLoad();
175 NavigateToLocalUrl(kPage1Path);
176 RunAndVerify();
177 EXPECT_EQ(kPage1Title, last_page_title_);
178
179 // Try an invalid GoForward before loading a different page, and
180 // assert that the page still loads correctly.
181 ExpectPageLoad();
182 client_session_->GetNavigationFeature()->GoForward(kDummyTabId);
183 NavigateToLocalUrl(kPage2Path);
184 RunAndVerify();
185 EXPECT_EQ(kPage2Title, last_page_title_);
133 } 186 }
134 187
135 } // namespace 188 } // namespace
136 } // namespace blimp 189 } // namespace blimp
OLDNEW
« no previous file with comments | « no previous file | blimp/engine/session/tab.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698