1 /*
2 * Copyright (C) 2022 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include "src/trace_processor/prelude/table_functions/connected_flow.h"
18
19 #include "test/gtest_and_gmock.h"
20
21 namespace perfetto {
22 namespace trace_processor {
23 namespace {
24
TEST(ConnectedFlow,SliceTableNullConstraint)25 TEST(ConnectedFlow, SliceTableNullConstraint) {
26 // Insert a row to make sure that we are not returning an empty table just
27 // because the source is empty.
28 TraceStorage storage;
29 storage.mutable_slice_table()->Insert({});
30
31 ConnectedFlow generator{ConnectedFlow::Mode::kDirectlyConnectedFlow,
32 &storage};
33
34 // Check that if we pass start_id = NULL as a constraint, we correctly return
35 // an empty table.
36 std::unique_ptr<Table> res;
37 Constraint c{tables::ConnectedFlowTable::ColumnIndex::start_id, FilterOp::kEq,
38 SqlValue()};
39 base::Status status = generator.ComputeTable({c}, {}, BitVector(), res);
40 ASSERT_TRUE(status.ok());
41 ASSERT_EQ(res->row_count(), 0u);
42 }
43
44 } // namespace
45 } // namespace trace_processor
46 } // namespace perfetto
47