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

Side by Side Diff: content/renderer/render_frame_impl_browsertest.cc

Issue 2484633004: Change Lo-Fi bool to bitmask to support multiple Previews types (Closed)
Patch Set: add back previews_unspecified Created 4 years 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/debug/leak_annotations.h" 8 #include "base/debug/leak_annotations.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "content/child/web_url_loader_impl.h" 10 #include "content/child/web_url_loader_impl.h"
11 #include "content/common/frame_messages.h" 11 #include "content/common/frame_messages.h"
12 #include "content/common/frame_owner_properties.h" 12 #include "content/common/frame_owner_properties.h"
13 #include "content/common/renderer.mojom.h" 13 #include "content/common/renderer.mojom.h"
14 #include "content/common/view_messages.h" 14 #include "content/common/view_messages.h"
15 #include "content/public/common/previews_state.h"
15 #include "content/public/renderer/document_state.h" 16 #include "content/public/renderer/document_state.h"
16 #include "content/public/test/frame_load_waiter.h" 17 #include "content/public/test/frame_load_waiter.h"
17 #include "content/public/test/render_view_test.h" 18 #include "content/public/test/render_view_test.h"
18 #include "content/public/test/test_utils.h" 19 #include "content/public/test/test_utils.h"
19 #include "content/renderer/navigation_state_impl.h" 20 #include "content/renderer/navigation_state_impl.h"
20 #include "content/renderer/render_frame_impl.h" 21 #include "content/renderer/render_frame_impl.h"
21 #include "content/renderer/render_view_impl.h" 22 #include "content/renderer/render_view_impl.h"
22 #include "content/test/fake_compositor_dependencies.h" 23 #include "content/test/fake_compositor_dependencies.h"
23 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
24 #include "third_party/WebKit/public/platform/WebEffectiveConnectionType.h" 25 #include "third_party/WebKit/public/platform/WebEffectiveConnectionType.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 77
77 void TearDown() override { 78 void TearDown() override {
78 #if defined(LEAK_SANITIZER) 79 #if defined(LEAK_SANITIZER)
79 // Do this before shutting down V8 in RenderViewTest::TearDown(). 80 // Do this before shutting down V8 in RenderViewTest::TearDown().
80 // http://crbug.com/328552 81 // http://crbug.com/328552
81 __lsan_do_leak_check(); 82 __lsan_do_leak_check();
82 #endif 83 #endif
83 RenderViewTest::TearDown(); 84 RenderViewTest::TearDown();
84 } 85 }
85 86
86 void SetIsUsingLoFi(RenderFrameImpl* frame, bool is_using_lofi) { 87 void SetPreviewsState(RenderFrameImpl* frame, int previews_state) {
nasko 2016/12/08 22:19:34 PreviewsState
megjablon 2016/12/09 20:35:55 Done.
87 frame->is_using_lofi_ = is_using_lofi; 88 frame->previews_state_ = previews_state;
88 } 89 }
89 90
90 void SetEffectionConnectionType(RenderFrameImpl* frame, 91 void SetEffectionConnectionType(RenderFrameImpl* frame,
91 blink::WebEffectiveConnectionType type) { 92 blink::WebEffectiveConnectionType type) {
92 frame->effective_connection_type_ = type; 93 frame->effective_connection_type_ = type;
93 } 94 }
94 95
95 RenderFrameImpl* GetMainRenderFrame() { 96 RenderFrameImpl* GetMainRenderFrame() {
96 return static_cast<RenderFrameImpl*>(view_->GetMainRenderFrame()); 97 return static_cast<RenderFrameImpl*>(view_->GetMainRenderFrame());
97 } 98 }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 static_cast<RenderViewImpl*>(view_)->OnMessageReceived(was_shown_message); 187 static_cast<RenderViewImpl*>(view_)->OnMessageReceived(was_shown_message);
187 188
188 // This test is primarily checking that this case does not crash, but 189 // This test is primarily checking that this case does not crash, but
189 // observers should still be notified. 190 // observers should still be notified.
190 EXPECT_TRUE(observer.visible()); 191 EXPECT_TRUE(observer.visible());
191 } 192 }
192 193
193 // Test that LoFi state only updates for new main frame documents. Subframes 194 // Test that LoFi state only updates for new main frame documents. Subframes
194 // inherit from the main frame and should not change at commit time. 195 // inherit from the main frame and should not change at commit time.
195 TEST_F(RenderFrameImplTest, LoFiNotUpdatedOnSubframeCommits) { 196 TEST_F(RenderFrameImplTest, LoFiNotUpdatedOnSubframeCommits) {
196 SetIsUsingLoFi(GetMainRenderFrame(), true); 197 SetPreviewsState(GetMainRenderFrame(), SERVER_LOFI_ON);
197 SetIsUsingLoFi(frame(), true); 198 SetPreviewsState(frame(), SERVER_LOFI_ON);
198 EXPECT_TRUE(GetMainRenderFrame()->IsUsingLoFi()); 199 EXPECT_EQ(SERVER_LOFI_ON, GetMainRenderFrame()->GetPreviewsState());
199 EXPECT_TRUE(frame()->IsUsingLoFi()); 200 EXPECT_EQ(SERVER_LOFI_ON, frame()->GetPreviewsState());
200 201
201 blink::WebHistoryItem item; 202 blink::WebHistoryItem item;
202 item.initialize(); 203 item.initialize();
203 204
204 // The main frame's and subframe's LoFi states should stay the same on 205 // The main frame's and subframe's LoFi states should stay the same on
205 // navigations within the page. 206 // navigations within the page.
206 frame()->didNavigateWithinPage(frame()->GetWebFrame(), item, 207 frame()->didNavigateWithinPage(frame()->GetWebFrame(), item,
207 blink::WebStandardCommit, true); 208 blink::WebStandardCommit, true);
208 EXPECT_TRUE(frame()->IsUsingLoFi()); 209 EXPECT_EQ(SERVER_LOFI_ON, frame()->GetPreviewsState());
209 GetMainRenderFrame()->didNavigateWithinPage( 210 GetMainRenderFrame()->didNavigateWithinPage(
210 GetMainRenderFrame()->GetWebFrame(), item, blink::WebStandardCommit, 211 GetMainRenderFrame()->GetWebFrame(), item, blink::WebStandardCommit,
211 true); 212 true);
212 EXPECT_TRUE(GetMainRenderFrame()->IsUsingLoFi()); 213 EXPECT_EQ(SERVER_LOFI_ON, GetMainRenderFrame()->GetPreviewsState());
213 214
214 // The subframe's LoFi state should not be reset on commit. 215 // The subframe's LoFi state should not be reset on commit.
215 DocumentState* document_state = 216 DocumentState* document_state =
216 DocumentState::FromDataSource(frame()->GetWebFrame()->dataSource()); 217 DocumentState::FromDataSource(frame()->GetWebFrame()->dataSource());
217 static_cast<NavigationStateImpl*>(document_state->navigation_state()) 218 static_cast<NavigationStateImpl*>(document_state->navigation_state())
218 ->set_was_within_same_page(false); 219 ->set_was_within_same_page(false);
219 220
220 frame()->didCommitProvisionalLoad(frame()->GetWebFrame(), item, 221 frame()->didCommitProvisionalLoad(frame()->GetWebFrame(), item,
221 blink::WebStandardCommit); 222 blink::WebStandardCommit);
222 EXPECT_TRUE(frame()->IsUsingLoFi()); 223 EXPECT_EQ(SERVER_LOFI_ON, frame()->GetPreviewsState());
223 224
224 // The main frame's LoFi state should be reset to off on commit. 225 // The main frame's LoFi state should be reset to off on commit.
225 document_state = DocumentState::FromDataSource( 226 document_state = DocumentState::FromDataSource(
226 GetMainRenderFrame()->GetWebFrame()->dataSource()); 227 GetMainRenderFrame()->GetWebFrame()->dataSource());
227 static_cast<NavigationStateImpl*>(document_state->navigation_state()) 228 static_cast<NavigationStateImpl*>(document_state->navigation_state())
228 ->set_was_within_same_page(false); 229 ->set_was_within_same_page(false);
229 230
230 // Calling didCommitProvisionalLoad is not representative of a full navigation 231 // Calling didCommitProvisionalLoad is not representative of a full navigation
231 // but serves the purpose of testing the LoFi state logic. 232 // but serves the purpose of testing the LoFi state logic.
232 GetMainRenderFrame()->didCommitProvisionalLoad( 233 GetMainRenderFrame()->didCommitProvisionalLoad(
233 GetMainRenderFrame()->GetWebFrame(), item, blink::WebStandardCommit); 234 GetMainRenderFrame()->GetWebFrame(), item, blink::WebStandardCommit);
234 EXPECT_FALSE(GetMainRenderFrame()->IsUsingLoFi()); 235 EXPECT_EQ(PREVIEWS_OFF, GetMainRenderFrame()->GetPreviewsState());
235 // The subframe would be deleted here after a cross-document navigation. It 236 // The subframe would be deleted here after a cross-document navigation. It
236 // happens to be left around in this test because this does not simulate the 237 // happens to be left around in this test because this does not simulate the
237 // frame detach. 238 // frame detach.
238 } 239 }
239 240
240 // Test that effective connection type only updates for new main frame 241 // Test that effective connection type only updates for new main frame
241 // documents. 242 // documents.
242 TEST_F(RenderFrameImplTest, EffectiveConnectionType) { 243 TEST_F(RenderFrameImplTest, EffectiveConnectionType) {
243 EXPECT_EQ(blink::WebEffectiveConnectionType::TypeUnknown, 244 EXPECT_EQ(blink::WebEffectiveConnectionType::TypeUnknown,
244 frame()->getEffectiveConnectionType()); 245 frame()->getEffectiveConnectionType());
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 common_params.url = GURL("data:text/html,max_zoomlimit_test"); 368 common_params.url = GURL("data:text/html,max_zoomlimit_test");
368 GetMainRenderFrame()->SetHostZoomLevel(common_params.url, kMaxZoomLevel); 369 GetMainRenderFrame()->SetHostZoomLevel(common_params.url, kMaxZoomLevel);
369 GetMainRenderFrame()->NavigateInternal( 370 GetMainRenderFrame()->NavigateInternal(
370 common_params, StartNavigationParams(), RequestNavigationParams(), 371 common_params, StartNavigationParams(), RequestNavigationParams(),
371 std::unique_ptr<StreamOverrideParameters>()); 372 std::unique_ptr<StreamOverrideParameters>());
372 ProcessPendingMessages(); 373 ProcessPendingMessages();
373 EXPECT_DOUBLE_EQ(kMaxZoomLevel, view_->GetWebView()->zoomLevel()); 374 EXPECT_DOUBLE_EQ(kMaxZoomLevel, view_->GetWebView()->zoomLevel());
374 } 375 }
375 376
376 } // namespace 377 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698