triClickText "text" — find control by text content and click it. Returns true on success. triClickText "needle" -> "OK" or "FAIL:not_found" / "FAIL:no_display". Returns a string (rather than a bool) so the tri runner can apply Capybara-style automatic synchronisation: if the text isn't on screen yet, the runner re-tries every poll_interval until the assertion timeout. Tests that previously had t
| 677 | C3DStatic* s = dynamic_cast<C3DStatic*>(display->GetCtrl(idc)); |
| 678 | if (s == nullptr) |
| 679 | return GameValue(Format("FAIL:no C3DStatic with idc %d", idc)); |
| 680 | for (int i = 0; i < s->GetLineCount(); i++) |
| 681 | { |
| 682 | std::string line = (const char*)s->GetLine(i); |
| 683 | std::size_t start = line.find_first_not_of(" \t\r\n"); |
| 684 | if (start != std::string::npos && line.compare(start, prefix.size(), prefix) == 0) |
| 685 | return GameValue(RString("OK")); |
| 686 | } |
| 687 | return GameValue(Format("FAIL:no line starts with '%s' (%d lines)", prefix.c_str(), s->GetLineCount())); |
| 688 | } |
| 689 | |
| 690 | /// triAssertControlLinesExclude [idc, "needle"] - assert no rendered line of the |
| 691 | /// active display's C3DStatic (idc) contains needle. Useful for catching explicit |
| 692 | /// line-break delimiters that split lines but still leak into the drawn substring. |
| 693 | GameValue TriAssertControlLinesExclude(const GameState* /*state*/, GameValuePar arg) |
| 694 | { |
| 695 | const GameArrayType& a = arg; |
| 696 | if (a.Size() < 2) |
| 697 | return GameValue(RString("FAIL:triAssertControlLinesExclude needs [idc, needle]")); |
| 698 | const int idc = static_cast<int>(static_cast<GameScalarType>(a[0])); |
| 699 | std::string needle = (const char*)static_cast<RString>(a[1]); |
| 700 | if (needle == "\\n") |
| 701 | needle = "\n"; |
| 702 | else if (needle == "\\r") |
| 703 | needle = "\r"; |
| 704 | ControlsContainer* display = GetActiveDisplayForSQF(); |
| 705 | if (display == nullptr) |
| 706 | return GameValue(RString("FAIL:no active display")); |
| 707 | C3DStatic* s = dynamic_cast<C3DStatic*>(display->GetCtrl(idc)); |
| 708 | if (s == nullptr) |
| 709 | return GameValue(Format("FAIL:no C3DStatic with idc %d", idc)); |
| 710 | for (int i = 0; i < s->GetLineCount(); i++) |
| 711 | { |
| 712 | std::string line = (const char*)s->GetLine(i); |
| 713 | if (line.find(needle) != std::string::npos) |
| 714 | return GameValue(Format("FAIL:line %d contains excluded text", i)); |
| 715 | } |
| 716 | return GameValue(RString("OK")); |
| 717 | } |
nothing calls this directly
no test coverage detected