final PolicyValueModifier modifier =
factory.createPolicyValueModifier(shell, SWT.NONE, policyName);
controller = new PolicyController(policyName, selector,
modifier, null, context);
final ResolvedDevicePolicy rdpOriginal =
deviceRAM.resolvePolicy(deviceName, policyName);
// pixelsx is overridden by Microsoft-WebTV.
assertEquals("Microsoft-WebTV does not override pixelsx",
deviceName, rdpOriginal.deviceName);
controller.setDeviceName(deviceName);
// Simulate changing from override to fallback by invoking the private
// PolicyController#handleFallbackSelection method.
try {
PrivateAccessor.invoke(controller,
"handleFallbackSelection", null, null);
} catch (Throwable throwable) {
throw new Exception(throwable);
}
// Retrieve the updated policy.
final ResolvedDevicePolicy rdpFallback =
deviceRAM.resolvePolicy(deviceName, policyName);
// pixelsx was overridden by Microsoft-WebTV but now falls back to TV.
assertEquals("Microsoft-WebTV does not inherit pixelsx from TV",
"TV", rdpFallback.deviceName);
// Simulate a Restore by invoking the private
// PolicyController#handleRestoreSelection method.
try {
PrivateAccessor.invoke(controller,
"handleRestoreSelection", null, null);
} catch (Throwable throwable) {
throw new Exception(throwable);
}
// Retrieve the updated policy.
final ResolvedDevicePolicy rdpRestore =
deviceRAM.resolvePolicy(deviceName, policyName);
// pixelsx has now been restored and should be overridden by
// Microsoft-WebTV.
assertEquals("Microsoft-WebTV does not override pixelsx",