summaryrefslogtreecommitdiffstats
path: root/toolkit/components/glean/gtest/TestFogIPC.cpp
blob: f0ac9c85ac3d62793c9ec4d930ce0193d0b6ce3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "gtest/gtest.h"

// NOTE: No ContentChild/Parent tests because it includes headers that aren't
// present in GTest builds (or something).

#include "mozilla/FOGIPC.h"
#include <functional>
#include "mozilla/ipc/ByteBuf.h"
#include "nsTArray.h"
#include "nsXULAppAPI.h"

using mozilla::ipc::ByteBuf;

TEST(FOG, TestFlushFOGData)
{
  // A "It doesn't explode" test.
  std::function<void(ByteBuf &&)> resolver = [](ByteBuf&& bufs) {};
  mozilla::glean::FlushFOGData(std::move(resolver));
}

TEST(FOG, TestFlushAllChildData)
{
  std::function<void(const nsTArray<ByteBuf>&&)> resolver =
      [](const nsTArray<ByteBuf>&& bufs) {
        ASSERT_TRUE(bufs.Length() == 0)
        << "Not expecting any bufs yet.";
      };
  mozilla::glean::FlushAllChildData(std::move(resolver));
}

TEST(FOG, FOGData)
{
  // Another "It doesn't explode" test.
  ByteBuf buf;
  mozilla::glean::FOGData(std::move(buf));
}

TEST(FOG, SendFOGData)
{
  ASSERT_EQ(XRE_GetProcessType(), GeckoProcessType_Default)
      << "If we can run a test as a different process type, we can write a "
         "test for this function.";
}