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

Side by Side Diff: content/browser/wake_lock/wake_lock_browsertest.cc

Issue 2126733002: Make ScreenWakeLock ContextLifecycleObserver instead of LocalFrameLifecycleObserver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: temp Created 4 years, 5 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/test/test_timeouts.h" 6 #include "base/test/test_timeouts.h"
7 #include "content/browser/wake_lock/wake_lock_service_context.h" 7 #include "content/browser/wake_lock/wake_lock_service_context.h"
8 #include "content/browser/web_contents/web_contents_impl.h" 8 #include "content/browser/web_contents/web_contents_impl.h"
9 #include "content/public/common/content_switches.h" 9 #include "content/public/common/content_switches.h"
10 #include "content/public/test/browser_test_utils.h" 10 #include "content/public/test/browser_test_utils.h"
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 embedded_test_server()->GetURL("/session_history/fragment.html")); 254 embedded_test_server()->GetURL("/session_history/fragment.html"));
255 GURL test_in_page_url(test_url.spec() + "#a"); 255 GURL test_in_page_url(test_url.spec() + "#a");
256 256
257 NavigateToURL(shell(), test_url); 257 NavigateToURL(shell(), test_url);
258 ScreenWakeLockInMainFrame(); 258 ScreenWakeLockInMainFrame();
259 259
260 NavigateToURL(shell(), test_in_page_url); 260 NavigateToURL(shell(), test_in_page_url);
261 EXPECT_TRUE(HasWakeLock()); 261 EXPECT_TRUE(HasWakeLock());
262 } 262 }
263 263
264 IN_PROC_BROWSER_TEST_F(WakeLockTest, UnlockAfterReload) {
haraken 2016/07/06 08:27:39 This test is testing if the wake lock is gone afte
dcheng 2016/07/06 08:34:42 Hmm, isn't this still a useful thing to test? It's
haraken 2016/07/06 08:51:23 Reload + WaitForLoadStop doesn't detach a document
alogvinov 2016/07/06 08:58:58 Is the problem that we are waiting for the wrong e
dcheng 2016/07/06 09:04:12 Assuming this is doing a "real" reload, the docume
haraken 2016/07/06 09:14:35 shell()->Reload(); fprintf(stderr, "%d\n", shell()
265 NavigateToURL(shell(), embedded_test_server()->GetURL("/simple_page.html"));
266 ScreenWakeLockInMainFrame();
267
268 shell()->Reload();
269 WaitForLoadStop(GetWebContents());
270
271 // Screen wake lock should be released after reload.
272 EXPECT_FALSE(HasWakeLock());
273 }
274
275 IN_PROC_BROWSER_TEST_F(WakeLockTest, BrowserInitiatedFrameNavigation) { 264 IN_PROC_BROWSER_TEST_F(WakeLockTest, BrowserInitiatedFrameNavigation) {
276 NavigateToURL(shell(), 265 NavigateToURL(shell(),
277 embedded_test_server()->GetURL("/frame_tree/2-4.html")); 266 embedded_test_server()->GetURL("/frame_tree/2-4.html"));
278 267
279 EXPECT_FALSE(HasWakeLock()); 268 EXPECT_FALSE(HasWakeLock());
280 269
281 // Lock screen in nested frame. 270 // Lock screen in nested frame.
282 EXPECT_TRUE(ExecuteScript(GetNestedFrame(), "screen.keepAwake = true;")); 271 EXPECT_TRUE(ExecuteScript(GetNestedFrame(), "screen.keepAwake = true;"));
283 WaitForPossibleUpdate(); 272 WaitForPossibleUpdate();
284 273
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 GetNestedFrame()->GetProcess(), 356 GetNestedFrame()->GetProcess(),
368 RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); 357 RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT);
369 GetNestedFrame()->GetProcess()->Shutdown(0, false); 358 GetNestedFrame()->GetProcess()->Shutdown(0, false);
370 watcher.Wait(); 359 watcher.Wait();
371 360
372 // Screen wake lock should be released. 361 // Screen wake lock should be released.
373 EXPECT_FALSE(HasWakeLock()); 362 EXPECT_FALSE(HasWakeLock());
374 } 363 }
375 364
376 } // namespace content 365 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698