@@ -4012,16 +4012,11 @@ class XmlUnitTestResultPrinter : public EmptyTestEventListener {
40124012 static void PrintXmlUnitTest(::std::ostream* stream,
40134013 const UnitTest& unit_test);
40144014
4015- // Produces a string representing the test properties in a result as space
4016- // delimited XML attributes based on the property key="value" pairs.
4017- // When the std::string is not empty, it includes a space at the beginning,
4018- // to delimit this attribute from prior attributes.
4019- static std::string TestPropertiesAsXmlAttributes(const TestResult& result);
4020-
40214015 // Streams an XML representation of the test properties of a TestResult
40224016 // object.
40234017 static void OutputXmlTestProperties(std::ostream* stream,
4024- const TestResult& result);
4018+ const TestResult& result,
4019+ const std::string& indent);
40254020
40264021 // The output file.
40274022 const std::string output_file_;
@@ -4355,7 +4350,7 @@ void XmlUnitTestResultPrinter::OutputXmlTestResult(::std::ostream* stream,
43554350 if (failures == 0 && skips == 0) {
43564351 *stream << ">\n";
43574352 }
4358- OutputXmlTestProperties(stream, result);
4353+ OutputXmlTestProperties(stream, result, /*indent=*/" " );
43594354 *stream << " </testcase>\n";
43604355 }
43614356}
@@ -4384,9 +4379,10 @@ void XmlUnitTestResultPrinter::PrintXmlTestSuite(std::ostream* stream,
43844379 OutputXmlAttribute(
43854380 stream, kTestsuite, "timestamp",
43864381 FormatEpochTimeInMillisAsIso8601(test_suite.start_timestamp()));
4387- *stream << TestPropertiesAsXmlAttributes(test_suite.ad_hoc_test_result());
43884382 }
43894383 *stream << ">\n";
4384+ OutputXmlTestProperties(stream, test_suite.ad_hoc_test_result(),
4385+ /*indent=*/" ");
43904386 for (int i = 0; i < test_suite.total_test_count(); ++i) {
43914387 if (test_suite.GetTestInfo(i)->is_reportable())
43924388 OutputXmlTestInfo(stream, test_suite.name(), *test_suite.GetTestInfo(i));
@@ -4424,11 +4420,12 @@ void XmlUnitTestResultPrinter::PrintXmlUnitTest(std::ostream* stream,
44244420 OutputXmlAttribute(stream, kTestsuites, "random_seed",
44254421 StreamableToString(unit_test.random_seed()));
44264422 }
4427- *stream << TestPropertiesAsXmlAttributes(unit_test.ad_hoc_test_result());
44284423
44294424 OutputXmlAttribute(stream, kTestsuites, "name", "AllTests");
44304425 *stream << ">\n";
44314426
4427+ OutputXmlTestProperties(stream, unit_test.ad_hoc_test_result(),
4428+ /*indent=*/" ");
44324429 for (int i = 0; i < unit_test.total_test_suite_count(); ++i) {
44334430 if (unit_test.GetTestSuite(i)->reportable_test_count() > 0)
44344431 PrintXmlTestSuite(stream, *unit_test.GetTestSuite(i));
@@ -4465,37 +4462,24 @@ void XmlUnitTestResultPrinter::PrintXmlTestsList(
44654462 *stream << "</" << kTestsuites << ">\n";
44664463}
44674464
4468- // Produces a string representing the test properties in a result as space
4469- // delimited XML attributes based on the property key="value" pairs.
4470- std::string XmlUnitTestResultPrinter::TestPropertiesAsXmlAttributes(
4471- const TestResult& result) {
4472- Message attributes;
4473- for (int i = 0; i < result.test_property_count(); ++i) {
4474- const TestProperty& property = result.GetTestProperty(i);
4475- attributes << " " << property.key() << "=" << "\""
4476- << EscapeXmlAttribute(property.value()) << "\"";
4477- }
4478- return attributes.GetString();
4479- }
4480-
44814465void XmlUnitTestResultPrinter::OutputXmlTestProperties(
4482- std::ostream* stream, const TestResult& result) {
4466+ std::ostream* stream, const TestResult& result, const std::string& indent ) {
44834467 const std::string kProperties = "properties";
44844468 const std::string kProperty = "property";
44854469
44864470 if (result.test_property_count() <= 0) {
44874471 return;
44884472 }
44894473
4490- *stream << " <" << kProperties << ">\n";
4474+ *stream << indent << " <" << kProperties << ">\n";
44914475 for (int i = 0; i < result.test_property_count(); ++i) {
44924476 const TestProperty& property = result.GetTestProperty(i);
4493- *stream << " <" << kProperty;
4477+ *stream << indent << " <" << kProperty;
44944478 *stream << " name=\"" << EscapeXmlAttribute(property.key()) << "\"";
44954479 *stream << " value=\"" << EscapeXmlAttribute(property.value()) << "\"";
44964480 *stream << "/>\n";
44974481 }
4498- *stream << " </" << kProperties << ">\n";
4482+ *stream << indent << " </" << kProperties << ">\n";
44994483}
45004484
45014485// End XmlUnitTestResultPrinter
0 commit comments