/*
 * 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 SchemeTonalSpotTest : McuTestCase {
	public SchemeTonalSpotTest () {
		base ("scheme_tonal_spot");
		add_test ("blue_light_scheme", test_blue_light_scheme);
		add_test ("blue_dark_scheme", test_blue_dark_scheme);
		add_test ("3rd_party_light_scheme", test_3rd_party_light_scheme);
		add_test ("3rd_party_dark_scheme", test_3rd_party_dark_scheme);
		add_test ("light_scheme_from_high_chroma_color", test_light_scheme_from_high_chroma_color);
		add_test ("dark_scheme_from_high_chroma_color", test_dark_scheme_from_high_chroma_color);
		add_test ("light_content_scheme_from_high_chroma_color", test_light_content_scheme_from_high_chroma_color);
		add_test ("dark_content_scheme_from_high_chroma_color", test_dark_content_scheme_from_high_chroma_color);
	}

	public override void set_up () {}

	public void test_blue_light_scheme () {
		var scheme = new SchemeTonalSpot (Hct.from_int ((int) 0xff0000ffu), false, 0.0);

		McuAssert.int_and_uint_equal (scheme.primary, 0xff555992u);
	}

	public void test_blue_dark_scheme () {
		var scheme = new SchemeTonalSpot (Hct.from_int ((int) 0xff0000ffu), true, 0.0);

		McuAssert.int_and_uint_equal (scheme.primary, 0xffbec2ffu);
	}

	public void test_3rd_party_light_scheme () {
		var scheme = new SchemeTonalSpot (Hct.from_int ((int) 0xff6750a4u), false, 0.0);

		McuAssert.int_and_uint_equal (scheme.primary, 0xff65558fu);
		McuAssert.int_and_uint_equal (scheme.secondary, 0xff625b71u);
		McuAssert.int_and_uint_equal (scheme.tertiary, 0xff7e5260u);
		McuAssert.int_and_uint_equal (scheme.surface, 0xfffdf7ffu);
		McuAssert.int_and_uint_equal (scheme.on_surface, 0xff1d1b20u);
	}

	public void test_3rd_party_dark_scheme () {
		var scheme = new SchemeTonalSpot (Hct.from_int ((int) 0xff6750a4u), true, 0.0);

		McuAssert.int_and_uint_equal (scheme.primary, 0xffcfbdfeu);
		McuAssert.int_and_uint_equal (scheme.secondary, 0xffcbc2dbu);
		McuAssert.int_and_uint_equal (scheme.tertiary, 0xffefb8c8u);
		McuAssert.int_and_uint_equal (scheme.surface, 0xff141218u);
		McuAssert.int_and_uint_equal (scheme.on_surface, 0xffe6e0e9u);
	}

	public void test_light_scheme_from_high_chroma_color () {
		var scheme = new SchemeTonalSpot (Hct.from_int ((int) 0xfffa2becu), false, 0.0);

		McuAssert.int_and_uint_equal (scheme.primary, 0xff814c77u);
		McuAssert.int_and_uint_equal (scheme.on_primary, 0xffffffffu);
		McuAssert.int_and_uint_equal (scheme.primary_container, 0xffffd7f3u);
		McuAssert.int_and_uint_equal (scheme.on_primary_container, 0xff67355eu);
		McuAssert.int_and_uint_equal (scheme.secondary, 0xff6e5868u);
		McuAssert.int_and_uint_equal (scheme.on_secondary, 0xffffffffu);
		McuAssert.int_and_uint_equal (scheme.secondary_container, 0xfff8daeeu);
		McuAssert.int_and_uint_equal (scheme.on_secondary_container, 0xff554050u);
		McuAssert.int_and_uint_equal (scheme.tertiary, 0xff815343u);
		McuAssert.int_and_uint_equal (scheme.on_tertiary, 0xffffffffu);
		McuAssert.int_and_uint_equal (scheme.tertiary_container, 0xffffdbd0u);
		McuAssert.int_and_uint_equal (scheme.on_tertiary_container, 0xff663c2du);
		McuAssert.int_and_uint_equal (scheme.error, 0xffba1a1au);
		McuAssert.int_and_uint_equal (scheme.on_error, 0xffffffffu);
		McuAssert.int_and_uint_equal (scheme.error_container, 0xffffdad6u);
		McuAssert.int_and_uint_equal (scheme.on_error_container, 0xff93000au);
		McuAssert.int_and_uint_equal (scheme.background, 0xfffff7f9u);
		McuAssert.int_and_uint_equal (scheme.on_background, 0xff201a1eu);
		McuAssert.int_and_uint_equal (scheme.surface, 0xfffff7f9u);
		McuAssert.int_and_uint_equal (scheme.on_surface, 0xff201a1eu);
		McuAssert.int_and_uint_equal (scheme.surface_variant, 0xffeedee7u);
		McuAssert.int_and_uint_equal (scheme.on_surface_variant, 0xff4e444bu);
		McuAssert.int_and_uint_equal (scheme.outline, 0xff80747bu);
		McuAssert.int_and_uint_equal (scheme.outline_variant, 0xffd2c2cbu);
		McuAssert.int_and_uint_equal (scheme.shadow, 0xff000000u);
		McuAssert.int_and_uint_equal (scheme.scrim, 0xff000000u);
		McuAssert.int_and_uint_equal (scheme.inverse_surface, 0xff362e33u);
		McuAssert.int_and_uint_equal (scheme.inverse_on_surface, 0xfffaedf3u);
		McuAssert.int_and_uint_equal (scheme.inverse_primary, 0xfff3b2e4u);
	}

	public void test_dark_scheme_from_high_chroma_color () {
		var scheme = new SchemeTonalSpot (Hct.from_int ((int) 0xfffa2becu), true, 0.0);

		McuAssert.int_and_uint_equal (scheme.primary, 0xfff3b2e4u);
		McuAssert.int_and_uint_equal (scheme.on_primary, 0xff4d1f47u);
		McuAssert.int_and_uint_equal (scheme.primary_container, 0xff67355eu);
		McuAssert.int_and_uint_equal (scheme.on_primary_container, 0xffffd7f3u);
		McuAssert.int_and_uint_equal (scheme.secondary, 0xffdbbed1u);
		McuAssert.int_and_uint_equal (scheme.on_secondary, 0xff3e2a39u);
		McuAssert.int_and_uint_equal (scheme.secondary_container, 0xff554050u);
		McuAssert.int_and_uint_equal (scheme.on_secondary_container, 0xfff8daeeu);
		McuAssert.int_and_uint_equal (scheme.tertiary, 0xfff5b9a5u);
		McuAssert.int_and_uint_equal (scheme.on_tertiary, 0xff4c2619u);
		McuAssert.int_and_uint_equal (scheme.tertiary_container, 0xff663c2du);
		McuAssert.int_and_uint_equal (scheme.on_tertiary_container, 0xffffdbd0u);
		McuAssert.int_and_uint_equal (scheme.error, 0xffffb4abu);
		McuAssert.int_and_uint_equal (scheme.on_error, 0xff690005u);
		McuAssert.int_and_uint_equal (scheme.error_container, 0xff93000au);
		McuAssert.int_and_uint_equal (scheme.on_error_container, 0xffffdad6u);
		McuAssert.int_and_uint_equal (scheme.background, 0xff181216u);
		McuAssert.int_and_uint_equal (scheme.on_background, 0xffecdfe5u);
		McuAssert.int_and_uint_equal (scheme.surface, 0xff181216u);
		McuAssert.int_and_uint_equal (scheme.on_surface, 0xffecdfe5u);
		McuAssert.int_and_uint_equal (scheme.surface_variant, 0xff4e444bu);
		McuAssert.int_and_uint_equal (scheme.on_surface_variant, 0xffd2c2cbu);
		McuAssert.int_and_uint_equal (scheme.outline, 0xff9a8d95u);
		McuAssert.int_and_uint_equal (scheme.outline_variant, 0xff4e444bu);
		McuAssert.int_and_uint_equal (scheme.shadow, 0xff000000u);
		McuAssert.int_and_uint_equal (scheme.scrim, 0xff000000u);
		McuAssert.int_and_uint_equal (scheme.inverse_surface, 0xffecdfe5u);
		McuAssert.int_and_uint_equal (scheme.inverse_on_surface, 0xff362e33u);
		McuAssert.int_and_uint_equal (scheme.inverse_primary, 0xff814c77u);
	}

	public void test_light_content_scheme_from_high_chroma_color () {
		var scheme = new SchemeContent (Hct.from_int ((int) 0xfffa2becu), false, 0.0);

		McuAssert.int_and_uint_equal (scheme.primary, 0xffa7009eu);
		McuAssert.int_and_uint_equal (scheme.on_primary, 0xffffffffu);
		McuAssert.int_and_uint_equal (scheme.primary_container, 0xffd100c6u);
		McuAssert.int_and_uint_equal (scheme.on_primary_container, 0xfffffbffu);
		McuAssert.int_and_uint_equal (scheme.secondary, 0xff9e2d93u);
		McuAssert.int_and_uint_equal (scheme.on_secondary, 0xffffffffu);
		McuAssert.int_and_uint_equal (scheme.secondary_container, 0xffff83ecu);
		McuAssert.int_and_uint_equal (scheme.on_secondary_container, 0xff7c0276u);
		McuAssert.int_and_uint_equal (scheme.tertiary, 0xffb51830u);
		McuAssert.int_and_uint_equal (scheme.on_tertiary, 0xffffffffu);
		McuAssert.int_and_uint_equal (scheme.tertiary_container, 0xffd83546u);
		McuAssert.int_and_uint_equal (scheme.on_tertiary_container, 0xfffffbffu);
		McuAssert.int_and_uint_equal (scheme.error, 0xffba1a1au);
		McuAssert.int_and_uint_equal (scheme.on_error, 0xffffffffu);
		McuAssert.int_and_uint_equal (scheme.error_container, 0xffffdad6u);
		McuAssert.int_and_uint_equal (scheme.on_error_container, 0xff93000au);
		McuAssert.int_and_uint_equal (scheme.background, 0xfffff7f9u);
		McuAssert.int_and_uint_equal (scheme.on_background, 0xff251722u);
		McuAssert.int_and_uint_equal (scheme.surface, 0xfffff7f9u);
		McuAssert.int_and_uint_equal (scheme.on_surface, 0xff251722u);
		McuAssert.int_and_uint_equal (scheme.surface_variant, 0xfff9daeeu);
		McuAssert.int_and_uint_equal (scheme.on_surface_variant, 0xff564050u);
		McuAssert.int_and_uint_equal (scheme.outline, 0xff897081u);
		McuAssert.int_and_uint_equal (scheme.outline_variant, 0xffdcbed2u);
		McuAssert.int_and_uint_equal (scheme.shadow, 0xff000000u);
		McuAssert.int_and_uint_equal (scheme.scrim, 0xff000000u);
		McuAssert.int_and_uint_equal (scheme.inverse_surface, 0xff3b2c37u);
		McuAssert.int_and_uint_equal (scheme.inverse_on_surface, 0xffffebf6u);
		McuAssert.int_and_uint_equal (scheme.inverse_primary, 0xffffabeeu);
	}

	public void test_dark_content_scheme_from_high_chroma_color () {
		var scheme = new SchemeContent (Hct.from_int ((int) 0xfffa2becu), true, 0.0);

		McuAssert.int_and_uint_equal (scheme.primary, 0xffffabeeu);
		McuAssert.int_and_uint_equal (scheme.on_primary, 0xff5c0057u);
		McuAssert.int_and_uint_equal (scheme.primary_container, 0xfffa2becu);
		McuAssert.int_and_uint_equal (scheme.on_primary_container, 0xff51004cu);
		McuAssert.int_and_uint_equal (scheme.secondary, 0xffffabeeu);
		McuAssert.int_and_uint_equal (scheme.on_secondary, 0xff5c0057u);
		McuAssert.int_and_uint_equal (scheme.secondary_container, 0xff840f7cu);
		McuAssert.int_and_uint_equal (scheme.on_secondary_container, 0xffff93ecu);
		McuAssert.int_and_uint_equal (scheme.tertiary, 0xffffb3b2u);
		McuAssert.int_and_uint_equal (scheme.on_tertiary, 0xff680014u);
		McuAssert.int_and_uint_equal (scheme.tertiary_container, 0xffff525fu);
		McuAssert.int_and_uint_equal (scheme.on_tertiary_container, 0xff5b0010u);
		McuAssert.int_and_uint_equal (scheme.error, 0xffffb4abu);
		McuAssert.int_and_uint_equal (scheme.on_error, 0xff690005u);
		McuAssert.int_and_uint_equal (scheme.error_container, 0xff93000au);
		McuAssert.int_and_uint_equal (scheme.on_error_container, 0xffffdad6u);
		McuAssert.int_and_uint_equal (scheme.background, 0xff1c0f19u);
		McuAssert.int_and_uint_equal (scheme.on_background, 0xfff4dcebu);
		McuAssert.int_and_uint_equal (scheme.surface, 0xff1c0f19u);
		McuAssert.int_and_uint_equal (scheme.on_surface, 0xfff4dcebu);
		McuAssert.int_and_uint_equal (scheme.surface_variant, 0xff564050u);
		McuAssert.int_and_uint_equal (scheme.on_surface_variant, 0xffdcbed2u);
		McuAssert.int_and_uint_equal (scheme.outline, 0xffa4899bu);
		McuAssert.int_and_uint_equal (scheme.outline_variant, 0xff564050u);
		McuAssert.int_and_uint_equal (scheme.shadow, 0xff000000u);
		McuAssert.int_and_uint_equal (scheme.scrim, 0xff000000u);
		McuAssert.int_and_uint_equal (scheme.inverse_surface, 0xfff4dcebu);
		McuAssert.int_and_uint_equal (scheme.inverse_on_surface, 0xff3b2c37u);
		McuAssert.int_and_uint_equal (scheme.inverse_primary, 0xffab00a2u);
	}

	public override void tear_down () {}
}
