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

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

Issue 2272513003: Blimp GoBack browser test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: wip 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/test/data/hello.html » ('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 30 matching lines...) Expand all
41 // Create a headless client on UI thread. 41 // Create a headless client on UI thread.
42 client_session_.reset(new client::TestClientSession); 42 client_session_.reset(new client::TestClientSession);
43 43
44 // Set feature delegates. 44 // Set feature delegates.
45 client_session_->GetNavigationFeature()->SetDelegate( 45 client_session_->GetNavigationFeature()->SetDelegate(
46 kDummyTabId, &client_nav_feature_delegate_); 46 kDummyTabId, &client_nav_feature_delegate_);
47 client_session_->GetRenderWidgetFeature()->SetDelegate( 47 client_session_->GetRenderWidgetFeature()->SetDelegate(
48 kDummyTabId, &client_rw_feature_delegate_); 48 kDummyTabId, &client_rw_feature_delegate_);
49 client_session_->GetImeFeature()->set_delegate( 49 client_session_->GetImeFeature()->set_delegate(
50 &client_ime_feature_delegate_); 50 &client_ime_feature_delegate_);
51
52 // Skip assigner. Engine info is already available.
53 client_session_->ConnectWithAssignment(client::ASSIGNMENT_REQUEST_RESULT_OK,
54 GetAssignment());
55 client_session_->GetTabControlFeature()->SetSizeAndScale(
56 gfx::Size(100, 100), 1);
57 client_session_->GetTabControlFeature()->CreateTab(kDummyTabId);
58
59 // Record the last page title known to the client. Page loads will sometimes
60 // involve multiple title changes in transition, including the requested
61 // URL. When a page is done loading, the last title should be the one from
62 // the <title> tag.
63 ON_CALL(client_nav_feature_delegate_,
64 OnTitleChanged(kDummyTabId, testing::_))
65 .WillByDefault(testing::SaveArg<1>(&last_page_title_));
66
67 EXPECT_TRUE(embedded_test_server()->Start());
68 }
69
70 // Given a path on the embedded local server, tell the client to navigate to
71 // that page by URL.
72 void NavigateToLocalUrl(std::string path) {
Kevin M 2016/08/25 19:44:41 const std::string&
Brian Goldman 2016/08/26 15:55:03 Done.
73 GURL url = embedded_test_server()->GetURL(path);
74 client_session_->GetNavigationFeature()->NavigateToUrlText(kDummyTabId,
75 url.spec());
Kevin M 2016/08/25 19:44:41 Odd indentation - run "git cl format"
Brian Goldman 2016/08/26 15:55:03 I ran the command and it changed the indentation o
76 }
77
78 // Set mock expectations that a page will load. A page has loaded when the
79 // page load status changes to true, and then to false.
80 void ExpectPageLoad() {
81 testing::InSequence s;
82
83 // There may be redundant events indicating the page load status is true,
84 // so allow more than one.
85 EXPECT_CALL(client_nav_feature_delegate_,
86 OnLoadingChanged(kDummyTabId, true))
87 .Times(testing::AtLeast(1));
88 EXPECT_CALL(client_nav_feature_delegate_,
89 OnLoadingChanged(kDummyTabId, false))
90 .WillOnce(InvokeWithoutArgs(this,
91 &EngineBrowserTest::SignalCompletion));
92 }
93
94 void RunAndVerify() {
95 RunUntilCompletion();
96 testing::Mock::VerifyAndClearExpectations(&client_rw_feature_delegate_);
97 testing::Mock::VerifyAndClearExpectations(&client_nav_feature_delegate_);
51 } 98 }
52 99
53 client::MockNavigationFeatureDelegate client_nav_feature_delegate_; 100 client::MockNavigationFeatureDelegate client_nav_feature_delegate_;
54 client::MockRenderWidgetFeatureDelegate client_rw_feature_delegate_; 101 client::MockRenderWidgetFeatureDelegate client_rw_feature_delegate_;
55 client::MockImeFeatureDelegate client_ime_feature_delegate_; 102 client::MockImeFeatureDelegate client_ime_feature_delegate_;
56 std::unique_ptr<client::TestClientSession> client_session_; 103 std::unique_ptr<client::TestClientSession> client_session_;
104 std::string last_page_title_;
57 105
58 private: 106 private:
59 DISALLOW_COPY_AND_ASSIGN(EngineBrowserTest); 107 DISALLOW_COPY_AND_ASSIGN(EngineBrowserTest);
60 }; 108 };
61 109
62 IN_PROC_BROWSER_TEST_F(EngineBrowserTest, LoadUrl) { 110 IN_PROC_BROWSER_TEST_F(EngineBrowserTest, LoadUrl) {
63 testing::InSequence s; 111 EXPECT_CALL(client_rw_feature_delegate_, OnRenderWidgetCreated(1));
112 ExpectPageLoad();
113 NavigateToLocalUrl("/page1.html");
114 RunAndVerify();
115 EXPECT_EQ("page1", last_page_title_);
116 }
64 117
65 EXPECT_TRUE(embedded_test_server()->Start()); 118 IN_PROC_BROWSER_TEST_F(EngineBrowserTest, GoBack) {
66 GURL url = embedded_test_server()->GetURL("/hello.html"); 119 ExpectPageLoad();
120 NavigateToLocalUrl("/page1.html");
121 RunAndVerify();
122 EXPECT_EQ("page1", last_page_title_);
67 123
68 EXPECT_CALL(client_rw_feature_delegate_, OnRenderWidgetCreated(1)); 124 ExpectPageLoad();
69 EXPECT_CALL(client_nav_feature_delegate_, 125 NavigateToLocalUrl("/page2.html");
70 OnTitleChanged(kDummyTabId, url.GetContent())); 126 RunAndVerify();
71 EXPECT_CALL(client_nav_feature_delegate_, 127 EXPECT_EQ("page2", last_page_title_);
72 OnTitleChanged(kDummyTabId, "hello"))
73 .WillOnce(InvokeWithoutArgs(this, &EngineBrowserTest::SignalCompletion));
74 128
75 // Skip assigner. Engine info is already available. 129 ExpectPageLoad();
76 client_session_->ConnectWithAssignment(client::ASSIGNMENT_REQUEST_RESULT_OK, 130 client_session_->GetNavigationFeature()->GoBack(kDummyTabId);
77 GetAssignment()); 131 RunAndVerify();
78 client_session_->GetTabControlFeature()->SetSizeAndScale(gfx::Size(100, 100), 132 EXPECT_EQ("page1", last_page_title_);
79 1);
80 client_session_->GetTabControlFeature()->CreateTab(kDummyTabId);
81 client_session_->GetNavigationFeature()->NavigateToUrlText(kDummyTabId,
82 url.spec());
83
84 RunUntilCompletion();
85 } 133 }
86 134
87 } // namespace 135 } // namespace
88 } // namespace blimp 136 } // namespace blimp
OLDNEW
« no previous file with comments | « no previous file | blimp/test/data/hello.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698