/*
 * 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 SchemeExpressiveTest : McuTestCase {
	private sealed Hct source_color_hct = Hct.from_int ((int) 0xff0000ffu);

	public SchemeExpressiveTest () {
		base ("scheme_expressive");
		add_test ("key_colors", test_key_colors);
		add_test ("light_theme_min_contrast_primary", test_light_theme_min_contrast_primary);
		add_test ("light_theme_standard_contrast_primary", test_light_theme_standard_contrast_primary);
		add_test ("light_theme_max_contrast_primary", test_light_theme_max_contrast_primary);
		add_test ("light_theme_min_contrast_primary_container", test_light_theme_min_contrast_primary_container);
		add_test ("light_theme_standard_contrast_primary_container", test_light_theme_standard_contrast_primary_container);
		add_test ("light_theme_max_contrast_primary_container", test_light_theme_max_contrast_primary_container);
		add_test ("light_theme_min_contrast_on_primary_container", test_light_theme_min_contrast_on_primary_container);
		add_test ("light_theme_standard_contrast_on_primary_container", test_light_theme_standard_contrast_on_primary_container);
		add_test ("light_theme_max_contrast_on_primary_container", test_light_theme_max_contrast_on_primary_container);
		add_test ("light_theme_min_contrast_surface", test_light_theme_min_contrast_surface);
		add_test ("light_theme_standard_contrast_surface", test_light_theme_standard_contrast_surface);
		add_test ("light_theme_max_contrast_surface", test_light_theme_max_contrast_surface);
		add_test ("dark_theme_min_contrast_primary", test_dark_theme_min_contrast_primary);
		add_test ("dark_theme_standard_contrast_primary", test_dark_theme_standard_contrast_primary);
		add_test ("dark_theme_max_contrast_primary", test_dark_theme_max_contrast_primary);
		add_test ("dark_theme_min_contrast_primary_container", test_dark_theme_min_contrast_primary_container);
		add_test ("dark_theme_standard_contrast_primary_container", test_dark_theme_standard_contrast_primary_container);
		add_test ("dark_theme_max_contrast_primary_container", test_dark_theme_max_contrast_primary_container);
		add_test ("dark_theme_min_contrast_on_primary_container", test_dark_theme_min_contrast_on_primary_container);
		add_test ("dark_theme_standard_contrast_on_primary_container", test_dark_theme_standard_contrast_on_primary_container);
		add_test ("dark_theme_max_contrast_on_primary_container", test_dark_theme_max_contrast_on_primary_container);
		add_test ("dark_theme_min_contrast_surface", test_dark_theme_min_contrast_surface);
		add_test ("dark_theme_standard_contrast_surface", test_dark_theme_standard_contrast_surface);
		add_test ("dark_theme_max_contrast_surface", test_dark_theme_max_contrast_surface);
	}

	public override void set_up () {}

	public void test_key_colors () {
		var answer = new SchemeExpressive (source_color_hct, false, 0.0);

		McuAssert.int_and_uint_equal (answer.primary_palette_key_color, 0xff35855fu);
		McuAssert.int_and_uint_equal (answer.secondary_palette_key_color, 0xff8c6d8cu);
		McuAssert.int_and_uint_equal (answer.tertiary_palette_key_color, 0xff806ea1u);
		McuAssert.int_and_uint_equal (answer.neutral_palette_key_color, 0xff79757fu);
		McuAssert.int_and_uint_equal (answer.neutral_variant_palette_key_color, 0xff7a7585u);
	}

	public void test_light_theme_min_contrast_primary () {
		var answer = new SchemeExpressive (source_color_hct, false, -1.0);

		McuAssert.int_and_uint_equal (answer.primary, 0xff32835du);
	}

	public void test_light_theme_standard_contrast_primary () {
		var answer = new SchemeExpressive (source_color_hct, false, 0.0);

		McuAssert.int_and_uint_equal (answer.primary, 0xff146c48u);
	}

	public void test_light_theme_max_contrast_primary () {
		var answer = new SchemeExpressive (source_color_hct, false, 1.0);

		McuAssert.int_and_uint_equal (answer.primary, 0xff00341fu);
	}

	public void test_light_theme_min_contrast_primary_container () {
		var answer = new SchemeExpressive (source_color_hct, false, -1.0);

		McuAssert.int_and_uint_equal (answer.primary_container, 0xff99eabdu);
	}

	public void test_light_theme_standard_contrast_primary_container () {
		var answer = new SchemeExpressive (source_color_hct, false, 0.0);

		McuAssert.int_and_uint_equal (answer.primary_container, 0xffa2f4c6u);
	}

	public void test_light_theme_max_contrast_primary_container () {
		var answer = new SchemeExpressive (source_color_hct, false, 1.0);

		McuAssert.int_and_uint_equal (answer.primary_container, 0xff005436u);
	}

	public void test_light_theme_min_contrast_on_primary_container () {
		var answer = new SchemeExpressive (source_color_hct, false, -1.0);

		McuAssert.int_and_uint_equal (answer.on_primary_container, 0xff388862u);
	}

	public void test_light_theme_standard_contrast_on_primary_container () {
		var answer = new SchemeExpressive (source_color_hct, false, 0.0);

		McuAssert.int_and_uint_equal (answer.on_primary_container, 0xff005234u);
	}

	public void test_light_theme_max_contrast_on_primary_container () {
		var answer = new SchemeExpressive (source_color_hct, false, 1.0);

		McuAssert.int_and_uint_equal (answer.on_primary_container, 0xffffffffu);
	}

	public void test_light_theme_min_contrast_surface () {
		var answer = new SchemeExpressive (source_color_hct, false, -1.0);

		McuAssert.int_and_uint_equal (answer.surface, 0xfffdf7ffu);
	}

	public void test_light_theme_standard_contrast_surface () {
		var answer = new SchemeExpressive (source_color_hct, false, 0.0);

		McuAssert.int_and_uint_equal (answer.surface, 0xfffdf7ffu);
	}

	public void test_light_theme_max_contrast_surface () {
		var answer = new SchemeExpressive (source_color_hct, false, 1.0);

		McuAssert.int_and_uint_equal (answer.surface, 0xfffdf7ffu);
	}

	public void test_dark_theme_min_contrast_primary () {
		var answer = new SchemeExpressive (source_color_hct, true, -1.0);

		McuAssert.int_and_uint_equal (answer.primary, 0xff51a078u);
	}

	public void test_dark_theme_standard_contrast_primary () {
		var answer = new SchemeExpressive (source_color_hct, true, 0.0);

		McuAssert.int_and_uint_equal (answer.primary, 0xff87d7abu);
	}

	public void test_dark_theme_max_contrast_primary () {
		var answer = new SchemeExpressive (source_color_hct, true, 1.0);

		McuAssert.int_and_uint_equal (answer.primary, 0xffbbffd7u);
	}

	public void test_dark_theme_min_contrast_primary_container () {
		var answer = new SchemeExpressive (source_color_hct, true, -1.0);

		McuAssert.int_and_uint_equal (answer.primary_container, 0xff00432au);
	}

	public void test_dark_theme_standard_contrast_primary_container () {
		var answer = new SchemeExpressive (source_color_hct, true, 0.0);

		McuAssert.int_and_uint_equal (answer.primary_container, 0xff005234u);
	}

	public void test_dark_theme_max_contrast_primary_container () {
		var answer = new SchemeExpressive (source_color_hct, true, 1.0);

		McuAssert.int_and_uint_equal (answer.primary_container, 0xff83d3a8u);
	}

	public void test_dark_theme_min_contrast_on_primary_container () {
		var answer = new SchemeExpressive (source_color_hct, true, -1.0);

		McuAssert.int_and_uint_equal (answer.on_primary_container, 0xff43936cu);
	}

	public void test_dark_theme_standard_contrast_on_primary_container () {
		var answer = new SchemeExpressive (source_color_hct, true, 0.0);

		McuAssert.int_and_uint_equal (answer.on_primary_container, 0xffa2f4c6u);
	}

	public void test_dark_theme_max_contrast_on_primary_container () {
		var answer = new SchemeExpressive (source_color_hct, true, 1.0);

		McuAssert.int_and_uint_equal (answer.on_primary_container, 0xff000e06u);
	}

	public void test_dark_theme_min_contrast_surface () {
		var answer = new SchemeExpressive (source_color_hct, true, -1.0);

		McuAssert.int_and_uint_equal (answer.surface, 0xff14121au);
	}

	public void test_dark_theme_standard_contrast_surface () {
		var answer = new SchemeExpressive (source_color_hct, true, 0.0);

		McuAssert.int_and_uint_equal (answer.surface, 0xff14121au);
	}

	public void test_dark_theme_max_contrast_surface () {
		var answer = new SchemeExpressive (source_color_hct, true, 1.0);

		McuAssert.int_and_uint_equal (answer.surface, 0xff14121au);
	}

	public override void tear_down () {}
}
