tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

TestHelpers.cpp (2423B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
      5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #include "TestHelpers.h"
      8 
      9 #include "gtest/gtest.h"
     10 #include "mozilla/dom/quota/CommonMetadata.h"
     11 #include "nsString.h"
     12 
     13 namespace testing::internal {
     14 
     15 GTEST_API_ ::testing::AssertionResult CmpHelperSTREQ(const char* s1_expression,
     16                                                     const char* s2_expression,
     17                                                     const nsAString& s1,
     18                                                     const nsAString& s2) {
     19  if (s1.Equals(s2)) {
     20    return ::testing::AssertionSuccess();
     21  }
     22 
     23  return ::testing::internal::EqFailure(
     24      s1_expression, s2_expression,
     25      std::string(NS_ConvertUTF16toUTF8(s1).get()),
     26      std::string(NS_ConvertUTF16toUTF8(s2).get()),
     27      /* ignore case */ false);
     28 }
     29 
     30 GTEST_API_ ::testing::AssertionResult CmpHelperSTREQ(const char* s1_expression,
     31                                                     const char* s2_expression,
     32                                                     const nsACString& s1,
     33                                                     const nsACString& s2) {
     34  if (s1.Equals(s2)) {
     35    return ::testing::AssertionSuccess();
     36  }
     37 
     38  return ::testing::internal::EqFailure(s1_expression, s2_expression,
     39                                        std::string(s1), std::string(s2),
     40                                        /* ignore case */ false);
     41 }
     42 
     43 }  // namespace testing::internal
     44 
     45 namespace mozilla::dom::fs::test {
     46 
     47 quota::OriginMetadata GetTestOriginMetadata() {
     48  return quota::OriginMetadata{""_ns,
     49                               "example.com"_ns,
     50                               "http://example.com"_ns,
     51                               "http://example.com"_ns,
     52                               /* aIsPrivate */ false,
     53                               quota::PERSISTENCE_TYPE_DEFAULT};
     54 }
     55 
     56 quota::ClientMetadata GetTestClientMetadata() {
     57  return quota::ClientMetadata{GetTestOriginMetadata(),
     58                               quota::Client::FILESYSTEM};
     59 }
     60 
     61 const Origin& GetTestOrigin() {
     62  static const Origin origin = "http://example.com"_ns;
     63  return origin;
     64 }
     65 
     66 }  // namespace mozilla::dom::fs::test