private void SetState_Click(object sender, RoutedEventArgs e) { RevealBrushState state = RevealBrushState.Pressed; RevealBrush.SetState(Border4SetStatePressed, state); TestResult.Text = "SetState_Click: Clicked"; }
bool VerifyBorderLight(RevealBrush testBrush, bool value) { _revealBrushTestApi.RevealBrush = testBrush; bool borderLightSet = _revealBrushTestApi.IsBorderLightSet; return(value ? borderLightSet : !borderLightSet); }
bool VerifyHoverLight(RevealBrush testBrush, bool value) { _revealBrushTestApi.RevealBrush = testBrush; bool hoverLightSet = _revealBrushTestApi.IsHoverLightSet; return(value ? hoverLightSet : !hoverLightSet); }
private void HoverLight_ValidatePointerOverState() { if (!ValidateEffectsPresent()) { return; } using (var logger = new ResultsLogger("PointerOver", TestResult)) { string targetText = TargetComboBox.GetSelectedText(); Control target = FindName(targetText) as Control; // It is more complex to validate Reveal hover brush targeting on ListViewItem // since it uses several brushes applied to the internal ListViewItemChrome. Skip the check here. bool lightTargetingResult = true; if (targetText != "NormalListViewItem") { RevealBrush revealHoverBrush = target.Background as RevealBrush; lightTargetingResult = VerifyHoverBrushTargeting(revealHoverBrush); } logger.Verify(lightTargetingResult, "lightTargetingResult:" + lightTargetingResult); var lights = GetElementForHoverLight(target).Lights; bool lightCountResult = lights.Count == 2; // Reveal Press light is also present logger.Verify(lightCountResult, "lightCountResult:" + lightCountResult); var hoverLight = _revealTestApi.GetAsRevealHoverLight(lights[0]); logger.Verify(hoverLight != null, "HoverLight should be non-null"); bool lightValidationResult = HoverLight_ValidatePointerOver(hoverLight); logger.Verify(lightValidationResult, "lightValidationResult: " + lightValidationResult); } }
bool VerifyAmbientLight(RevealBrush testBrush, bool value) { _revealBrushTestApi.RevealBrush = testBrush; bool ambientLightSet = _revealBrushTestApi.IsAmbientLightSet; return(value ? ambientLightSet : !ambientLightSet); }
bool VerifyRevealBrush(RevealBrush testBrush) { _revealBrushTestApi.RevealBrush = testBrush; bool isInFallbackMode = _revealBrushTestApi.IsInFallbackMode; CompositionBrush compositionBrush = _revealBrushTestApi.CompositionBrush; return(!isInFallbackMode && (compositionBrush != null && compositionBrush is CompositionEffectBrush)); }
// Toggle ForceFallback property and validate brush + light state of two easily accessible (Default VSM state) brushes private void RunRevealAlwaysUseFallback() { _revealBrushTestApi.RevealBrush = LargeButton.Background as RevealBrush; bool isInFallbackMode = _revealBrushTestApi.IsInFallbackMode; if (isInFallbackMode) { TestResult.Text = "RevealAlwaysUseFallback: Skipped"; } else { // 1. Force fallback + validate AlwaysUseFallbackHelper(true); RevealBrush largeButtonBackgroundBrush = LargeButton.Background as RevealBrush; RevealBrush largeButtonBorderBrush = LargeButton.BorderBrush as RevealBrush; // Validate brushes bool fallbackBackgroundBrushResult = VerifyFallbackColor(largeButtonBackgroundBrush, Colors.Orange); bool fallbackBorderBrushResult = VerifyFallbackColor(largeButtonBorderBrush, Colors.Transparent); // Validate lights bool fallbackBackroundLightResult = VerifyAmbientLight(largeButtonBackgroundBrush, true) && VerifyBorderLight(largeButtonBackgroundBrush, false) && VerifyHoverLight(largeButtonBackgroundBrush, false); bool fallbackBorderLightResult = VerifyAmbientLight(largeButtonBorderBrush, true) && VerifyBorderLight(largeButtonBorderBrush, false) && VerifyHoverLight(largeButtonBorderBrush, false); // 2. Unforce fallback + validate AlwaysUseFallbackHelper(false); // Validate brushes bool backgroundBrushResult = VerifyRevealBrush(largeButtonBackgroundBrush); bool borderBrushResult = VerifyRevealBrush(largeButtonBorderBrush); // Validate lights bool backroundLightResult = VerifyAmbientLight(largeButtonBackgroundBrush, true) && VerifyBorderLight(largeButtonBackgroundBrush, false) && VerifyHoverLight(largeButtonBackgroundBrush, true); bool borderLightResult = VerifyAmbientLight(largeButtonBorderBrush, true) && VerifyBorderLight(largeButtonBorderBrush, true) && VerifyHoverLight(largeButtonBorderBrush, false); bool brushesResult = fallbackBackgroundBrushResult && fallbackBorderBrushResult && backgroundBrushResult && borderBrushResult; bool lightsResult = fallbackBackroundLightResult && fallbackBorderLightResult && backroundLightResult && borderLightResult; bool result = brushesResult && lightsResult; string brushesResultString = System.String.Format("({0},{1},{2},{3})", fallbackBackgroundBrushResult, fallbackBorderBrushResult, backgroundBrushResult, borderBrushResult); string lightsResultString = System.String.Format("({0},{1},{2},{3})", fallbackBackroundLightResult, fallbackBorderLightResult, backroundLightResult, borderLightResult); TestResult.Text = result ? "" : "Errors: brushes=" + brushesResultString + ", lights=" + lightsResultString; } }
private void HoverLight_ValidateNormalState() { if (!ValidateEffectsPresent()) { return; } using (var logger = new ResultsLogger("Normal", TestResult)) { if (_normalStateCheckNumber < 1 || _normalStateCheckNumber > 2) { logger.LogError("Error: unpexected call to HoverLight_ValidateNormalState"); return; } bool isInitialCheck = _normalStateCheckNumber == 1; _normalStateCheckNumber++; string targetText = TargetComboBox.GetSelectedText(); Control target = FindName(targetText) as Control; // It is more complex to validate Reveal hover bursh targeting on ListViewItem // since it uses several brushes applied to the internal ListViewItemChrome. Skip the check here. bool lightTargetingResult = true; if (targetText != "NormalListViewItem") { RevealBrush revealHoverBrush = target.Background as RevealBrush; lightTargetingResult = VerifyHoverBrushTargeting(revealHoverBrush); } logger.Verify(lightTargetingResult, "lightTargetingResult:" + lightTargetingResult); var lights = GetElementForHoverLight(target).Lights; // No lights expected if we've never hovered over this Button bool lightCountResult = isInitialCheck ? lights.Count == 0 : lights.Count == 2; logger.Verify(lightCountResult, "lightCountResult:" + lightCountResult); bool lightValidationResult = true; // If we have hovered over the target, validate Reveal light is properly in normal state if (!isInitialCheck) { var hoverLight = _revealTestApi.GetAsRevealHoverLight(lights[0]); lightValidationResult = HoverLight_ValidateNormal(hoverLight); } logger.Verify(lightValidationResult, "lightValidationResult: " + lightValidationResult); } }
bool VerifyFallbackColor(RevealBrush testBrush, Color fallbackColor) { _revealBrushTestApi.RevealBrush = testBrush; bool isInFallbackMode = _revealBrushTestApi.IsInFallbackMode; CompositionBrush compositionBrush = _revealBrushTestApi.CompositionBrush; // In fallbackmode, comp brush is set to null if color is transparent // it's used to boost performance for LVIP. if (isInFallbackMode && fallbackColor.Equals(Colors.Transparent)) { return(compositionBrush == null); } return(isInFallbackMode && (compositionBrush != null && compositionBrush is CompositionColorBrush) && (compositionBrush as CompositionColorBrush).Color.Equals(fallbackColor)); }
bool VerifyHoverBrushTargeting(RevealBrush testBrush) { return(VerifyAmbientLight(testBrush, true) && VerifyBorderLight(testBrush, false) && VerifyHoverLight(testBrush, true)); }