/*
 * Copyright 2021 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * ---------------------------------------------------------------------
 *
 * Portions of this file were modified and ported to Vala by Victor Vintorez in 2026.
 * These modifications are licensed under the European Union Public License (EUPL),
 * Version 1.2 or later. You may obtain a copy of the License at:
 * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
 */

using GLib;
using MaterialColorUtilities;

public class BlendTest : McuTestCase {
	private const int red = (int) 0xffff0000u;
	private const int blue = (int) 0xff0000ffu;
	private const int green = (int) 0xff00ff00u;
	private const int yellow = (int) 0xffffff00u;

	public BlendTest() {
		base("blend_tests");
		add_test("red_to_blue", test_red_to_blue);
		add_test("red_to_green", test_red_to_green);
		add_test("red_to_yellow", test_red_to_yellow);
		add_test("blue_to_red", test_blue_to_red);
		add_test("blue_to_yellow", test_blue_to_yellow);
		add_test("green_to_blue", test_green_to_blue);
		add_test("green_to_red", test_green_to_red);
		add_test("green_to_yellow", test_green_to_yellow);
		add_test("yellow_to_blue", test_yellow_to_blue);
		add_test("yellow_to_green", test_yellow_to_green);
		add_test("yellow_to_red", test_yellow_to_red);
	}

	public override void set_up() {}

	public void test_red_to_blue() {
		var answer = Blend.harmonize(red, blue);

		McuAssert.int_and_uint_equal(answer, 0xffFB0057u);
	}

	public void test_red_to_green() {
		var answer = Blend.harmonize(red, green);

		McuAssert.int_and_uint_equal(answer, 0xffD85600u);
	}

	public void test_red_to_yellow() {
		var answer = Blend.harmonize(red, yellow);

		McuAssert.int_and_uint_equal(answer, 0xffD85600u);
	}

	public void test_blue_to_red() {
		var answer = Blend.harmonize(blue, red);

		McuAssert.int_and_uint_equal(answer, 0xff5700DCu);
	}

	public void test_blue_to_yellow() {
		var answer = Blend.harmonize(blue, yellow);

		McuAssert.int_and_uint_equal(answer, 0xff0047A3u);
	}

	public void test_green_to_blue() {
		var answer = Blend.harmonize(green, blue);

		McuAssert.int_and_uint_equal(answer, 0xff00FC94u);
	}

	public void test_green_to_red() {
		var answer = Blend.harmonize(green, red);

		McuAssert.int_and_uint_equal(answer, 0xffB1F000u);
	}

	public void test_green_to_yellow() {
		var answer = Blend.harmonize(green, yellow);

		McuAssert.int_and_uint_equal(answer, 0xffB1F000u);
	}

	public void test_yellow_to_blue() {
		var answer = Blend.harmonize(yellow, blue);

		McuAssert.int_and_uint_equal(answer, 0xffEBFFBAu);
	}

	public void test_yellow_to_green() {
		var answer = Blend.harmonize(yellow, green);

		McuAssert.int_and_uint_equal(answer, 0xffEBFFBAu);
	}

	public void test_yellow_to_red() {
		var answer = Blend.harmonize(yellow, red);

		McuAssert.int_and_uint_equal(answer, 0xffFFF6E3u);
	}

	public override void tear_down() {}
}
