• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/perfetto_sql/intrinsics/table_functions/connected_flow.h"
18 
19 #include <memory>
20 
21 #include "perfetto/ext/base/status_or.h"
22 #include "perfetto/trace_processor/basic_types.h"
23 #include "src/base/test/status_matchers.h"
24 #include "src/trace_processor/db/table.h"
25 #include "src/trace_processor/storage/trace_storage.h"
26 #include "test/gtest_and_gmock.h"
27 
28 namespace perfetto::trace_processor {
29 namespace {
30 
TEST(ConnectedFlow,SliceTableNullConstraint)31 TEST(ConnectedFlow, SliceTableNullConstraint) {
32   // Insert a row to make sure that we are not returning an empty table just
33   // because the source is empty.
34   TraceStorage storage;
35   storage.mutable_slice_table()->Insert({});
36 
37   ConnectedFlow generator{ConnectedFlow::Mode::kDirectlyConnectedFlow,
38                           &storage};
39 
40   // Check that if we pass start_id = NULL as a constraint, we correctly return
41   // an empty table.
42   base::StatusOr<std::unique_ptr<Table>> res =
43       generator.ComputeTable({SqlValue()});
44   ASSERT_OK(res);
45   ASSERT_EQ(res->get()->row_count(), 0u);
46 }
47 
48 }  // namespace
49 }  // namespace perfetto::trace_processor
50