* '''Test plan for component''': repowerd
 * '''Component Checklist''': https://wiki.ubuntu.com/Process/Merges/Checklists/Common
 * '''Trunk URL''': lp:repowerd
 * '''Ubuntu Package URL (LP)''': http://launchpad.net/ubuntu/+source/repowerd

== Test Plan ==

Test target device: krillin, arale, frieza

=== Initial set up ===

 * Install latest image on phone
 * Build package containing the code to be landed, push them to and install them on the device
 * Reboot the phone

=== Steps to install repowerd from silo on device ===

 1. Boot the phone and ensure you have internet access.

 2. Prepare phone for (re)powerd upgrade.
  {{{
  $ sudo stop lightdm

  $ sudo stop repowerd
    or, if upgrading from a image that still has powerd:
  $ sudo stop powerd

  $ sudo umount /usr/share/powerd/device_configs/config-default.xml
  }}}
  Note: on some devices (e.g., N4) the umount will fail, since we
  don't ship a device-specific config file. Just ignore the failure.

 3. Install packages from silo <silo-num>

  On the *host* (desktop/laptop) system do:
  {{{
  $ citrain device-upgrade <silo-num> <device-password>
  }}}

 4. After reboot, check that repowerd is working:
  {{{
  $ ps -Af | grep repowerd
  }}}

=== How to deal with repower-data installation failure  ===

If the above fails with errors when trying to replace /usr/share/powerd/device_configs/config-default.xml while installing repowerd-data, try the following:

{{{
$ adb reboot recovery
$ adb shell
~ # export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
~ # mount /system
~ # chroot /system /bin/bash
root@localhost:/# dpkg -i /var/cache/apt/archives/<repowerd-data-deb>
root@localhost:/# sync
root@localhost:/# exit
}}}

= Manual Tests =

 * Test that the device can automatically shutdown the screen and suspend
 * Test that the device can wake up/suspend when pressing the power button
 * Test that the device can wake up when receiving a call
 * Test that the device can wake up when connecting/disconnecting usb charger
 * Unplug the usb cable and reboot the phone. It shouldn't take more than 30 seconds to reboot to the bootloader.
  * This is because if the phone takes more than 30 seconds to reboot it might mean that it's trying to suspend at the same time (bug 1452300)
 * Play a long (>2min) video and:
    1. Ensure the display stays on after the default blanking timeout has passed (60s)
    2. *After* step (1) (i.e. after having waited 60s) unplug the USB cable. The display should stay on (bug 1602933) until the video finishes.
 * Test that the phone actually suspends. A good test is to turn off wireless and BT, disconnect from any power sources and turn off the screen. After a while connect to the phone again and check /var/log/syslog. There should be a gap in the syslog entries corresponding to the duration of suspend.
 * Test that hw alarms are being triggered. Set an alarm (through the alarm clock) for a few minutes in the future and let the device suspend. The alarm should ring at the appropriate time.