Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

Commit

Permalink
vm_tools: Splits sommelier_tests
Browse files Browse the repository at this point in the history
+ Adds  directory to hold all of the test infra
* Migrates window tests out of sommelier-test.cc into sommelier-window-test.cc
* Renames sommelier_test.cc -> sommelier-test.cc to match naming conventions

BUG=b:255439799
TEST=meson build && ninja -C build && build/sommelier_test && build/sommelier_window_test

Change-Id: I2660b6b7683a26f1fdd2f5d52919cc46ccd22a4e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/4383405
Reviewed-by: Chloe Pelling <[email protected]>
Tested-by: Justin Huang <[email protected]>
Commit-Queue: Chloe Pelling <[email protected]>
Auto-Submit: Justin Huang <[email protected]>
  • Loading branch information
Justin Huang authored and Chromeos LUCI committed Apr 13, 2023
1 parent 6e9ecc1 commit 8180f85
Show file tree
Hide file tree
Showing 11 changed files with 703 additions and 546 deletions.
21 changes: 17 additions & 4 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,14 @@ executable("sommelier") {
}

if (use.test) {
executable("sommelier_test") {
sources = [ "sommelier_test.cc" ]

static_library("libsommelier-test") {
sources = [
"sommelier-test.cc",
"sommelier-window-test.cc",
"testing/mock-wayland-channel.cc",
"testing/sommelier-test-util.cc",
]
include_dirs = [ "testing" ]
pkg_deps = [ "pixman-1" ]

# gnlint: disable=GnLintCommonTesting
Expand All @@ -163,8 +168,16 @@ if (use.test) {
"gtest",
"pixman-1",
]
}

executable("sommelier_test") {
sources = [ "sommelier-test-main.cc" ]

defines = sommelier_defines
deps = [ ":libsommelier" ]
deps = [
":libsommelier",
":libsommelier-test",
]
}
}

Expand Down
10 changes: 8 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,16 @@ executable('sommelier',
)

if get_option('with_tests')
testing_include_directory = include_directories('testing')

sommelier_test = executable('sommelier_test',
install: true,
sources: [
'sommelier_test.cc',
'sommelier-test.cc',
'sommelier-test-main.cc',
'sommelier-window-test.cc',
'testing/mock-wayland-channel.cc',
'testing/sommelier-test-util.cc',
] + wl_outs,
link_with: libsommelier,
dependencies: [
Expand All @@ -208,7 +214,7 @@ if get_option('with_tests')
dependency('pixman-1')
],
cpp_args: cpp_args + sommelier_defines,
include_directories: includes,
include_directories: includes + testing_include_directory,
)

test('sommelier_test', sommelier_test)
Expand Down
12 changes: 12 additions & 0 deletions sommelier-test-main.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright 2023 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <gtest/gtest.h>

int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
testing::GTEST_FLAG(throw_on_failure) = true;
// TODO(nverne): set up logging?
return RUN_ALL_TESTS();
}
30 changes: 30 additions & 0 deletions sommelier-test.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright 2023 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <ctype.h>
#include <iostream>
#include <memory>
#include <string>
#include <vector>

#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include <sys/socket.h>

#include "sommelier.h" // NOLINT(build/include_directory)
#include "sommelier-util.h" // NOLINT(build/include_directory)
#include "testing/wayland-test-base.h" // NOLINT(build/include_directory)

namespace vm_tools {
namespace sommelier {

using WaylandTest = WaylandTestBase;

TEST_F(WaylandTest, CanCommitToEmptySurface) {
wl_surface* surface = wl_compositor_create_surface(ctx.compositor->internal);
wl_surface_commit(surface);
}

} // namespace sommelier
} // namespace vm_tools
Loading

0 comments on commit 8180f85

Please sign in to comment.