Make QUICHE unit tests work on platforms where googleurl is built without the system ICU support.

PiperOrigin-RevId: 493425776
diff --git a/quiche/common/platform/api/quiche_hostname_utils_test.cc b/quiche/common/platform/api/quiche_hostname_utils_test.cc
index 5d52c4f..59a38b3 100644
--- a/quiche/common/platform/api/quiche_hostname_utils_test.cc
+++ b/quiche/common/platform/api/quiche_hostname_utils_test.cc
@@ -8,6 +8,7 @@
 
 #include "absl/base/macros.h"
 #include "quiche/common/platform/api/quiche_test.h"
+#include "quiche/common/test_tools/quiche_test_utils.h"
 
 namespace quiche {
 namespace test {
@@ -71,10 +72,6 @@
           "........",
           "",
       },
-      {
-          "\xe5\x85\x89.google.com",
-          "xn--54q.google.com",
-      },
   };
   // clang-format on
 
@@ -82,6 +79,14 @@
     EXPECT_EQ(std::string(tests[i].expected),
               QuicheHostnameUtils::NormalizeHostname(tests[i].input));
   }
+
+  if (GoogleUrlSupportsIdnaForTest()) {
+    EXPECT_EQ("xn--54q.google.com", QuicheHostnameUtils::NormalizeHostname(
+                                        "\xe5\x85\x89.google.com"));
+  } else {
+    EXPECT_EQ(
+        "", QuicheHostnameUtils::NormalizeHostname("\xe5\x85\x89.google.com"));
+  }
 }
 
 }  // namespace
diff --git a/quiche/common/test_tools/quiche_test_utils.cc b/quiche/common/test_tools/quiche_test_utils.cc
index 91554ad..6470786 100644
--- a/quiche/common/test_tools/quiche_test_utils.cc
+++ b/quiche/common/test_tools/quiche_test_utils.cc
@@ -6,6 +6,7 @@
 
 #include <string>
 
+#include "url/gurl.h"
 #include "quiche/common/platform/api/quiche_logging.h"
 #include "quiche/common/platform/api/quiche_test.h"
 
@@ -87,5 +88,15 @@
   return iovec{const_cast<char*>(str.data()), static_cast<size_t>(str.size())};
 }
 
+bool GoogleUrlSupportsIdnaForTest() {
+  const std::string kTestInput = "https://\xe5\x85\x89.example.org/";
+  const std::string kExpectedOutput = "https://xn--54q.example.org/";
+
+  GURL url(kTestInput);
+  bool valid = url.is_valid() && url.spec() == kExpectedOutput;
+  QUICHE_CHECK(valid || !url.is_valid()) << url.spec();
+  return valid;
+}
+
 }  // namespace test
 }  // namespace quiche
diff --git a/quiche/common/test_tools/quiche_test_utils.h b/quiche/common/test_tools/quiche_test_utils.h
index e6a95d0..8fe1f7a 100644
--- a/quiche/common/test_tools/quiche_test_utils.h
+++ b/quiche/common/test_tools/quiche_test_utils.h
@@ -21,6 +21,11 @@
 // Create iovec that points to that data that `str` points to.
 iovec MakeIOVector(absl::string_view str);
 
+// Due to binary size considerations, googleurl library can be built with or
+// without IDNA support, meaning that we have to adjust our tests accordingly.
+// This function checks if IDNAs are supported.
+bool GoogleUrlSupportsIdnaForTest();
+
 }  // namespace test
 }  // namespace quiche
 
diff --git a/quiche/quic/core/http/spdy_server_push_utils_test.cc b/quiche/quic/core/http/spdy_server_push_utils_test.cc
index b11bcbe..f2d1855 100644
--- a/quiche/quic/core/http/spdy_server_push_utils_test.cc
+++ b/quiche/quic/core/http/spdy_server_push_utils_test.cc
@@ -6,9 +6,11 @@
 
 #include <memory>
 #include <string>
+#include <vector>
 
 #include "absl/base/macros.h"
 #include "quiche/quic/platform/api/quic_test.h"
+#include "quiche/common/test_tools/quiche_test_utils.h"
 
 using spdy::Http2HeaderBlock;
 
@@ -127,7 +129,7 @@
   const unsigned char SCHEME = (1u << 0);
   const unsigned char AUTH = (1u << 1);
   const unsigned char PATH = (1u << 2);
-  const std::pair<const char*, unsigned char> input_headers[] = {
+  std::vector<std::pair<const char*, unsigned char>> input_headers = {
       {"http", SCHEME | AUTH},
       {"https", SCHEME | AUTH},
       {"hTtP", SCHEME | AUTH},
@@ -135,7 +137,6 @@
       {"www.google.com", AUTH},
       {"90af90e0", AUTH},
       {"12foo%20-bar:00001233", AUTH},
-      {"GOO\u200b\u2060\ufeffgoo", AUTH},
       {"192.168.0.5", AUTH},
       {"[::ffff:192.168.0.1.]", AUTH},
       {"http:", AUTH},
@@ -157,11 +158,14 @@
       {"[::ffff:192.168", 0},
       {"]/", 0},
       {"//", 0}};
-  for (size_t i = 0; i < ABSL_ARRAYSIZE(input_headers); ++i) {
+  if (quiche::test::GoogleUrlSupportsIdnaForTest()) {
+    input_headers.push_back({"GOO\u200b\u2060\ufeffgoo", AUTH});
+  }
+  for (size_t i = 0; i < input_headers.size(); ++i) {
     bool should_accept = (input_headers[i].second & SCHEME);
-    for (size_t j = 0; j < ABSL_ARRAYSIZE(input_headers); ++j) {
+    for (size_t j = 0; j < input_headers.size(); ++j) {
       bool should_accept_2 = should_accept && (input_headers[j].second & AUTH);
-      for (size_t k = 0; k < ABSL_ARRAYSIZE(input_headers); ++k) {
+      for (size_t k = 0; k < input_headers.size(); ++k) {
         // |should_accept_3| indicates whether or not GetPushPromiseUrl() is
         // expected to accept this input combination.
         bool should_accept_3 =