Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/xpcom/tests/gtest/TestEventTargetQI.cpp
Line
Count
Source (jump to first uncovered line)
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
5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#include "mozilla/LazyIdleThread.h"
8
#include "mozilla/SharedThreadPool.h"
9
#include "mozilla/SystemGroup.h"
10
#include "mozilla/ThrottledEventQueue.h"
11
#include "nsComponentManagerUtils.h"
12
#include "nsCOMPtr.h"
13
#include "nsThreadPool.h"
14
#include "nsThreadUtils.h"
15
#include "nsXPCOM.h"
16
#include "nsXPCOMCIDInternal.h"
17
#include "gtest/gtest.h"
18
19
using namespace mozilla;
20
21
TEST(TestEventTargetQI, ThreadPool)
22
0
{
23
0
  nsCOMPtr<nsIThreadPool> thing = new nsThreadPool();
24
0
25
0
  nsCOMPtr<nsISerialEventTarget> serial = do_QueryInterface(thing);
26
0
  EXPECT_FALSE(serial);
27
0
28
0
  nsCOMPtr<nsIEventTarget> target = do_QueryInterface(thing);
29
0
  EXPECT_TRUE(target);
30
0
31
0
  thing->Shutdown();
32
0
}
33
34
TEST(TestEventTargetQI, SharedThreadPool)
35
0
{
36
0
  nsCOMPtr<nsIThreadPool> thing = SharedThreadPool::Get(NS_LITERAL_CSTRING("TestPool"), 1);
37
0
  EXPECT_TRUE(thing);
38
0
39
0
  nsCOMPtr<nsISerialEventTarget> serial = do_QueryInterface(thing);
40
0
  EXPECT_FALSE(serial);
41
0
42
0
  nsCOMPtr<nsIEventTarget> target = do_QueryInterface(thing);
43
0
  EXPECT_TRUE(target);
44
0
}
45
46
TEST(TestEventTargetQI, Thread)
47
0
{
48
0
  nsCOMPtr<nsIThread> thing = do_GetCurrentThread();
49
0
  EXPECT_TRUE(thing);
50
0
51
0
  nsCOMPtr<nsISerialEventTarget> serial = do_QueryInterface(thing);
52
0
  EXPECT_TRUE(serial);
53
0
54
0
  nsCOMPtr<nsIEventTarget> target = do_QueryInterface(thing);
55
0
  EXPECT_TRUE(target);
56
0
}
57
58
TEST(TestEventTargetQI, ThrottledEventQueue)
59
0
{
60
0
  nsCOMPtr<nsIThread> thread = do_GetCurrentThread();
61
0
  RefPtr<ThrottledEventQueue> thing = ThrottledEventQueue::Create(thread);
62
0
  EXPECT_TRUE(thing);
63
0
64
0
  nsCOMPtr<nsISerialEventTarget> serial = do_QueryInterface(thing);
65
0
  EXPECT_TRUE(serial);
66
0
67
0
  nsCOMPtr<nsIEventTarget> target = do_QueryInterface(thing);
68
0
  EXPECT_TRUE(target);
69
0
}
70
71
TEST(TestEventTargetQI, LazyIdleThread)
72
0
{
73
0
  nsCOMPtr<nsIThread> thing = new LazyIdleThread(0, NS_LITERAL_CSTRING("TestThread"));
74
0
  EXPECT_TRUE(thing);
75
0
76
0
  nsCOMPtr<nsISerialEventTarget> serial = do_QueryInterface(thing);
77
0
  EXPECT_TRUE(serial);
78
0
79
0
  nsCOMPtr<nsIEventTarget> target = do_QueryInterface(thing);
80
0
  EXPECT_TRUE(target);
81
0
82
0
  thing->Shutdown();
83
0
}
84
85
TEST(TestEventTargetQI, SchedulerGroup)
86
0
{
87
0
  nsCOMPtr<nsIEventTarget> thing = SystemGroup::EventTargetFor(TaskCategory::Other);
88
0
  EXPECT_TRUE(thing);
89
0
90
0
  nsCOMPtr<nsISerialEventTarget> serial = do_QueryInterface(thing);
91
0
  EXPECT_TRUE(serial);
92
0
93
0
  nsCOMPtr<nsIEventTarget> target = do_QueryInterface(thing);
94
0
  EXPECT_TRUE(target);
95
0
}