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

Side by Side Diff: device/power_save_blocker/power_save_blocker_x11.cc

Issue 2883903002: Add service unittest for WakeLockServiceImpl. (Closed)
Patch Set: Created 3 years, 7 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <X11/Xlib.h> 5 #include <X11/Xlib.h>
6 #include <X11/extensions/dpms.h> 6 #include <X11/extensions/dpms.h>
7 #include <X11/extensions/scrnsaver.h> 7 #include <X11/extensions/scrnsaver.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 } 434 }
435 return enabled; 435 return enabled;
436 } 436 }
437 437
438 bool PowerSaveBlocker::Delegate::XSSAvailable() { 438 bool PowerSaveBlocker::Delegate::XSSAvailable() {
439 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); 439 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread());
440 // X Screen Saver isn't accessible in headless mode. 440 // X Screen Saver isn't accessible in headless mode.
441 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kHeadless)) 441 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kHeadless))
442 return false; 442 return false;
443 XDisplay* display = gfx::GetXDisplay(); 443 XDisplay* display = gfx::GetXDisplay();
444 // In service_unittests context, XDisplay is not well initialized. passing a
blundell 2017/05/16 13:37:55 Did you check whether it's possible to initialize
ke.he 2017/05/17 07:19:54 Yes, I followed how the browser_main_runner.cc ini
blundell 2017/05/17 09:01:42 Short-circuiting out early in the test isn't conce
445 // nullptr to XScreenSaverQueryExtension() will cause crash.
446 if (!display)
447 return false;
444 int dummy; 448 int dummy;
445 int major; 449 int major;
446 int minor; 450 int minor;
447 451
448 if (!XScreenSaverQueryExtension(display, &dummy, &dummy)) 452 if (!XScreenSaverQueryExtension(display, &dummy, &dummy))
449 return false; 453 return false;
450 454
451 if (!XScreenSaverQueryVersion(display, &major, &minor)) 455 if (!XScreenSaverQueryVersion(display, &major, &minor))
452 return false; 456 return false;
453 457
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 } 507 }
504 } 508 }
505 509
506 PowerSaveBlocker::~PowerSaveBlocker() { 510 PowerSaveBlocker::~PowerSaveBlocker() {
507 delegate_->CleanUp(); 511 delegate_->CleanUp();
508 if (freedesktop_suspend_delegate_) 512 if (freedesktop_suspend_delegate_)
509 freedesktop_suspend_delegate_->CleanUp(); 513 freedesktop_suspend_delegate_->CleanUp();
510 } 514 }
511 515
512 } // namespace device 516 } // namespace device
OLDNEW
« no previous file with comments | « no previous file | services/device/BUILD.gn » ('j') | services/device/wake_lock/wake_lock_service_impl_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698