001 /* 002 * Created on Jan 22, 2011 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 005 * the License. You may obtain a copy of the License at 006 * 007 * http://www.apache.org/licenses/LICENSE-2.0 008 * 009 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 010 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 011 * specific language governing permissions and limitations under the License. 012 * 013 * Copyright @2011 the original author or authors. 014 */ 015 package org.fest.assertions.error; 016 017 import org.fest.assertions.data.*; 018 019 /** 020 * Creates an error message indicating that an assertion that verifies that a two colors are equal at a given 021 * point fails. 022 * 023 * @author Yvonne Wang 024 */ 025 public class ShouldBeEqualColors extends BasicErrorMessageFactory { 026 027 /** 028 * Creates a new <code>{@link ShouldBeEqualColors}</code>. 029 * @param expected the expected color. 030 * @param actual the actual color. 031 * @param point the point where {@code expected} and {@code actual} were compared at. 032 * @param offset helps decide if two colors are similar: two colors that are identical to the human eye may still have 033 * slightly different color values. For example, by using an offset of 1 we can indicate that a blue value of 60 is 034 * similar to a blue value of 61. 035 * @return the created {@code ErrorMessageFactory}. 036 */ 037 public static ErrorMessageFactory shouldBeEqualColors(RgbColor expected, RgbColor actual, Point point, Offset<?> offset) { 038 return new ShouldBeEqualColors(expected, actual, point, offset); 039 } 040 041 private ShouldBeEqualColors(RgbColor expected, RgbColor actual, Point point, Offset<?> offset) { 042 super("expected:<%s> but was:<%s> at:<%s> within offset:<%s>", expected, actual, point, offset.value); 043 } 044 }