To simulate the phone being unplugged from usb charging you can use:
$ adb shell dumpsys battery set usb 0
or if you're on a device Android 6.0 or higher you can use:
$ adb shell dumpsys battery unplug
To "plug" the phone back in, just reset it's charging status using:
$ adb shell dumpsys battery reset