// test_uicolors.cpp - M6 regression: widget base colours come from Config::uiColors
#include "../tttest.hpp"
#include "../ttgui.hpp"
using namespace ttgui;
TEST_CASE("uicolors: paper and selection colours are configurable, not literal", "[config][widget]"){
Config cfg=Config::defaults();
cfg.uiColors["paper"]=Color::rgb(10,20,30); cfg.uiColors["paperText"]=Color::rgb(200,210,220);
cfg.uiColors["selection"]=Color::rgb(1,2,3); cfg.uiColors["selectionText"]=Color::rgb(4,5,6);
EditBox ed; ed.cfg=&cfg; ed.setText("hi"); ed.bounds={0,0,20,1}; Canvas c1(20,2); ed.draw(c1);
CHECK(c1.get(2,0).st.bg==Color::rgb(10,20,30));
ListBox lb; lb.cfg=&cfg; lb.items={"one","two"}; lb.selected=0; lb.bounds={0,0,20,4}; Canvas c2(20,5); lb.draw(c2);
bool sawSelection=false; for(int y=0;y<5;y++) for(int x=0;x<20;x++) if(c2.get(x,y).st.bg==Color::rgb(1,2,3)) sawSelection=true;
CHECK(sawSelection);
// changing Config changes rendering (live re-theme path)
cfg.uiColors["paper"]=Color::rgb(99,88,77); Canvas c3(20,2); ed.draw(c3);
CHECK(c3.get(2,0).st.bg==Color::rgb(99,88,77));
// serialized + example coverage
std::string d=json::dump(cfg.toJson()); CHECK(d.find("uiColors")!=std::string::npos); CHECK(d.find("selection")!=std::string::npos);
Config loaded=Config::load("./rgui.env.json"); CHECK(loaded.warnings.empty()); CHECK(loaded.uiColors.count("paper")==1);
CHECK(loaded.uiColor("paper",Color::def())==Color::rgb(255,255,255));
}