-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathNativeLogEventTests.cpp
More file actions
47 lines (36 loc) · 1.42 KB
/
NativeLogEventTests.cpp
File metadata and controls
47 lines (36 loc) · 1.42 KB
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
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#include "pch.h"
#include <winrt/facebook.react.h>
#include <vector>
using namespace winrt::facebook::react;
using namespace winrt;
namespace ABITests {
TEST_CLASS (NativeLogEventTests) {
// RAII helper to ensure log handlers get unregistered
struct NativeLogInitializationGuard {
NativeLogInitializationGuard(::winrt::facebook::react::NativeLogHandler const &handler) noexcept {
m_registrationCookie = NativeLogEventSource::InitializeLogging(handler);
}
~NativeLogInitializationGuard() noexcept {
NativeLogEventSource::UninitializeLogging(m_registrationCookie);
}
private:
uint32_t m_registrationCookie;
};
public:
TEST_METHOD(NativeLogEventHandler_Registered) {
// anticipatory, see TODO below
std::vector<std::pair<::winrt::facebook::react::LogLevel, std::wstring>> logMessages;
NativeLogHandler handler{[&logMessages](::winrt::facebook::react::LogLevel l, hstring const &m) {
logMessages.emplace_back(l, m.c_str());
}};
NativeLogInitializationGuard initializationGuard{handler};
// TODO:
// Interact with RNW in such a way that it incurs logging, then verify the
// respective log message(s). To do that, we might have to interact via the
// existing unsafe ABI, then gradually replace those interactions with the
// safe ABI as we build it up.
}
};
} // namespace ABITests