Commit b48d249a authored by Nika Layzell's avatar Nika Layzell
Browse files

Bug 1761511 - Part 3: Switch builds over to use the new vendoring of gtest, r=ahal

This required some changes to tests to account for the version differences.

Differential Revision: https://phabricator.services.mozilla.com/D142610
parent e1ae2878
Loading
Loading
Loading
Loading
+0 −19
Original line number Diff line number Diff line
@@ -66,25 +66,6 @@ static RefPtr<EncodedFrame> CreateFrame(EncodedFrame::FrameType aType,
      aType, std::move(data));
}

namespace testing::internal {
// This makes the googletest framework treat nsTArray as an std::vector, so all
// the regular Matchers (like ElementsAre) work for it.
template <typename Element>
class StlContainerView<nsTArray<Element>> {
 public:
  typedef GTEST_REMOVE_CONST_(Element) RawElement;
  typedef std::vector<RawElement> type;
  typedef const type const_reference;
  static const_reference ConstReference(const nsTArray<Element>& aContainer) {
    StaticAssertTypeEq<Element, RawElement>();
    return type(aContainer.begin(), aContainer.end());
  }
  static type Copy(const nsTArray<Element>& aContainer) {
    return type(aContainer.begin(), aContainer.end());
  }
};
}  // namespace testing::internal

class MockContainerWriter : public ContainerWriter {
 public:
  MOCK_METHOD2(WriteEncodedTrack,
+2 −0
Original line number Diff line number Diff line
@@ -10,6 +10,8 @@
#include "mozilla/Assertions.h"
#include "mozilla/Attributes.h"

#include <algorithm>

#include "gtest/gtest.h"

MOZ_EXPORT bool gStackWalkTesterDummy = true;
+2 −89
Original line number Diff line number Diff line
@@ -13,96 +13,9 @@ with Files("**"):
    SCHEDULES.exclusive = ["gtest"]

if CONFIG["ENABLE_TESTS"]:
    gtest_exports = [
    EXPORTS.gtest += [
        "benchmark/BlackBox.h",
        "gtest/include/gtest/gtest-death-test.h",
        "gtest/include/gtest/gtest-message.h",
        "gtest/include/gtest/gtest-param-test.h",
        "gtest/include/gtest/gtest-printers.h",
        "gtest/include/gtest/gtest-spi.h",
        "gtest/include/gtest/gtest-test-part.h",
        "gtest/include/gtest/gtest-typed-test.h",
        "gtest/include/gtest/gtest.h",
        "gtest/include/gtest/gtest_pred_impl.h",
        "gtest/include/gtest/gtest_prod.h",
        "mozilla/MozGTestBench.h",
    ]
    EXPORTS.gtest += gtest_exports

    # webrtc.org unit tests use this include path
    EXPORTS.testing.gtest.include.gtest += gtest_exports

    # GTest internal are exposed in gtest.h. See comment in gtest.h
    EXPORTS.gtest.internal += [
        "gtest/include/gtest/internal/gtest-death-test-internal.h",
        "gtest/include/gtest/internal/gtest-filepath.h",
        "gtest/include/gtest/internal/gtest-internal.h",
        "gtest/include/gtest/internal/gtest-linked_ptr.h",
        "gtest/include/gtest/internal/gtest-param-util-generated.h",
        "gtest/include/gtest/internal/gtest-param-util.h",
        "gtest/include/gtest/internal/gtest-port-arch.h",
        "gtest/include/gtest/internal/gtest-port.h",
        "gtest/include/gtest/internal/gtest-string.h",
        "gtest/include/gtest/internal/gtest-tuple.h",
        "gtest/include/gtest/internal/gtest-type-util.h",
    ]

    EXPORTS.gtest.internal.custom += [
        "gtest/include/gtest/internal/custom/gtest-port.h",
        "gtest/include/gtest/internal/custom/gtest-printers.h",
    ]

    gmock_exports = [
        "gmock/include/gmock/gmock-actions.h",
        "gmock/include/gmock/gmock-cardinalities.h",
        "gmock/include/gmock/gmock-generated-actions.h",
        "gmock/include/gmock/gmock-generated-function-mockers.h",
        "gmock/include/gmock/gmock-generated-matchers.h",
        "gmock/include/gmock/gmock-generated-nice-strict.h",
        "gmock/include/gmock/gmock-matchers.h",
        "gmock/include/gmock/gmock-more-actions.h",
        "gmock/include/gmock/gmock-more-matchers.h",
        "gmock/include/gmock/gmock-spec-builders.h",
        "gmock/include/gmock/gmock.h",
    ]
    EXPORTS.gmock += gmock_exports

    # webrtc.org unit tests use this include path
    EXPORTS.testing.gmock.include.gmock += gmock_exports

    # gmock also includes internal interfaces in it's public header
    EXPORTS.gmock.internal += [
        "gmock/include/gmock/internal/gmock-generated-internal-utils.h",
        "gmock/include/gmock/internal/gmock-internal-utils.h",
        "gmock/include/gmock/internal/gmock-port.h",
    ]

    EXPORTS.gmock.internal.custom += [
        "gmock/include/gmock/internal/custom/gmock-generated-actions.h",
        "gmock/include/gmock/internal/custom/gmock-matchers.h",
        "gmock/include/gmock/internal/custom/gmock-port.h",
    ]

    SOURCES += [
        "gmock/src/gmock-all.cc",
        "gtest/src/gtest-all.cc",
    ]

    Library("gtest")

    LOCAL_INCLUDES += [
        "gmock",
        "gmock/include",
        "gtest",
        "gtest/include",
    ]

    if CONFIG["OS_ARCH"] == "WINNT":
        LOCAL_INCLUDES += [
            "/security/sandbox/chromium",
        ]
        DEFINES["UNICODE"] = True

    DIRS += ["benchmark", "mozilla"]

    FINAL_LIBRARY = "xul-gtest"
    DIRS += ["benchmark", "mozilla", "../../third_party/googletest"]
+1 −1
Original line number Diff line number Diff line
@@ -75,7 +75,7 @@ class MozillaPrinter : public EmptyTestEventListener {
              aTestPartResult.file_name(), aTestPartResult.line_number());
  }
  virtual void OnTestEnd(const TestInfo& aTestInfo) override {
    MOZ_PRINT("TEST-%s | %s.%s | test completed (time: %llims)\n",
    MOZ_PRINT("TEST-%s | %s.%s | test completed (time: %" PRIi64 "ms)\n",
              aTestInfo.result()->Passed() ? "PASS" : "UNEXPECTED-FAIL",
              aTestInfo.test_case_name(), aTestInfo.name(),
              aTestInfo.result()->elapsed_time());
+16 −0
Original line number Diff line number Diff line
# Customization Points

The custom directory is an injection point for custom user configurations.

## Header `gmock-port.h`

The following macros can be defined:

### Flag related macros:

*   `GMOCK_DECLARE_bool_(name)`
*   `GMOCK_DECLARE_int32_(name)`
*   `GMOCK_DECLARE_string_(name)`
*   `GMOCK_DEFINE_bool_(name, default_val, doc)`
*   `GMOCK_DEFINE_int32_(name, default_val, doc)`
*   `GMOCK_DEFINE_string_(name, default_val, doc)`
Loading