blob: 841934c2fd982e93b4657af0aaeb385e6c81417c (
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
48
49
50
51
52
53
|
// Copyright 2022 The Chromium Authors.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <memory>
#include "agent/src/event_posix.h"
#include "content_analysis/sdk/analysis_agent.h"
#include "gtest/gtest.h"
namespace content_analysis {
namespace sdk {
namespace testing {
std::unique_ptr<ContentAnalysisEventPosix> CreateEvent(
const BrowserInfo& browser_info,
ContentAnalysisRequest request) {
return std::make_unique<ContentAnalysisEventPosix>(
browser_info, std::move(request));
}
TEST(EventTest, Create_BrowserInfo) {
const BrowserInfo bi{12345, "/path/to/binary"};
ContentAnalysisRequest request;
*request.add_tags() = "foo";
request.set_request_token("req-token");
auto event = CreateEvent(bi, request);
ASSERT_TRUE(event);
ASSERT_EQ(bi.pid, event->GetBrowserInfo().pid);
ASSERT_EQ(bi.binary_path, event->GetBrowserInfo().binary_path);
}
TEST(EventTest, Create_Request) {
const BrowserInfo bi{ 12345, "/path/to/binary" };
ContentAnalysisRequest request;
*request.add_tags() = "foo";
request.set_request_token("req-token");
auto event = CreateEvent(bi, request);
ASSERT_TRUE(event);
ASSERT_EQ(1u, event->GetRequest().tags_size());
ASSERT_EQ(request.tags(0), event->GetRequest().tags(0));
ASSERT_TRUE(event->GetRequest().has_request_token());
ASSERT_EQ(request.request_token(), event->GetRequest().request_token());
}
} // namespace testing
} // namespace sdk
} // namespace content_analysis
|