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

	public SchemeNeutralTest () {
		base ("scheme_neutral");
		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_on_tertiary_container", test_dark_theme_min_contrast_on_tertiary_container);
		add_test ("dark_theme_standard_contrast_on_tertiary_container", test_dark_theme_standard_contrast_on_tertiary_container);
		add_test ("dark_theme_max_contrast_on_tertiary_container", test_dark_theme_max_contrast_on_tertiary_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 SchemeNeutral (source_color_hct, false, 0.0);

		McuAssert.int_and_uint_equal (answer.primary_palette_key_color, 0xff767685u);
		McuAssert.int_and_uint_equal (answer.secondary_palette_key_color, 0xff777680u);
		McuAssert.int_and_uint_equal (answer.tertiary_palette_key_color, 0xff75758bu);
		McuAssert.int_and_uint_equal (answer.neutral_palette_key_color, 0xff787678u);
		McuAssert.int_and_uint_equal (answer.neutral_variant_palette_key_color, 0xff787678u);
	}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	public void test_light_theme_max_contrast_on_primary_container () {
		var answer = new SchemeNeutral (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 SchemeNeutral (source_color_hct, false, -1.0);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	public void test_dark_theme_min_contrast_on_tertiary_container () {
		var answer = new SchemeNeutral (source_color_hct, true, -1.0);

		McuAssert.int_and_uint_equal (answer.on_tertiary_container, 0xff828299u);
	}

	public void test_dark_theme_standard_contrast_on_tertiary_container () {
		var answer = new SchemeNeutral (source_color_hct, true, 0.0);

		McuAssert.int_and_uint_equal (answer.on_tertiary_container, 0xffe1e0f9u);
	}

	public void test_dark_theme_max_contrast_on_tertiary_container () {
		var answer = new SchemeNeutral (source_color_hct, true, 1.0);

		McuAssert.int_and_uint_equal (answer.on_tertiary_container, 0xff080a1bu);
	}

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

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

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

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

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

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

	public override void tear_down () {}
}
