Skip to content

Commit

Permalink
Convert ApplicationManager Apptest to a unittest
Browse files Browse the repository at this point in the history
. removes mojo_shell_apptests (nothing left in them)
. removes capability_filter test (covered by connect unittests now)
. removes some remaining gles2 deps I noticed in native runner

R=sky@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1757833003

Cr-Commit-Position: refs/heads/master@{#378900}
  • Loading branch information
ben authored and Commit bot committed Mar 3, 2016
1 parent 6dc7870 commit 6a3bc7d
Show file tree
Hide file tree
Showing 22 changed files with 138 additions and 703 deletions.
1 change: 0 additions & 1 deletion BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,6 @@ group("mojo_apptests") {
"//mash/wm:tests",
"//media/mojo/services:tests",
"//mojo/services/network:apptests",
"//mojo/shell/tests:apptests",
"//ui/views/mus:tests",
]
}
Expand Down
3 changes: 1 addition & 2 deletions mojo/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ group("tests") {
"//mojo/services/network:apptests",
"//mojo/shell/public/cpp/tests:mojo_public_application_unittests",
"//mojo/shell/runner/host:mojo_runner_host_unittests",
"//mojo/shell/tests:apptests",
"//mojo/shell/tests:mojo_shell_unittests",
"//mojo/shell/tests",
]
}
2 changes: 0 additions & 2 deletions mojo/mojo_shell.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
'type': 'executable',
'sources': [
'shell/tests/loader_unittest.cc',
'shell/tests/capability_filter_unittest.cc',
],
'dependencies': [
'mojo_shell_lib',
Expand All @@ -63,7 +62,6 @@
'type': 'static_library',
'variables': {
'mojom_files': [
'shell/tests/capability_filter_unittest.mojom',
'shell/tests/test.mojom',
],
},
Expand Down
27 changes: 11 additions & 16 deletions mojo/shell/public/cpp/lib/shell_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,14 @@

namespace mojo {
namespace test {
class ShellTest::DefaultShellClient : public ShellClient {
public:
explicit DefaultShellClient(ShellTest* test) : test_(test) {}
~DefaultShellClient() override {}

private:
void Initialize(Connector* connector, const std::string& name,
uint32_t id, uint32_t user_id /* = 0 */) override {
test_->connector_ = connector;
test_->InitializeCalled(name, id, user_id);
}
ShellTestClient::ShellTestClient(ShellTest* test) : test_(test) {}
ShellTestClient::~ShellTestClient() {}

ShellTest* test_;

DISALLOW_COPY_AND_ASSIGN(DefaultShellClient);
};
void ShellTestClient::Initialize(Connector* connector, const std::string& name,
uint32_t id, uint32_t user_id) {
test_->InitializeCalled(connector, name, id, user_id);
}

ShellTest::ShellTest() {}
ShellTest::ShellTest(const std::string& test_name) : test_name_(test_name) {}
Expand All @@ -37,11 +29,14 @@ void ShellTest::InitTestName(const std::string& test_name) {
}

scoped_ptr<ShellClient> ShellTest::CreateShellClient() {
return make_scoped_ptr(new DefaultShellClient(this));
return make_scoped_ptr(new ShellTestClient(this));
}

void ShellTest::InitializeCalled(const std::string& name, uint32_t id,
void ShellTest::InitializeCalled(Connector* connector,
const std::string& name,
uint32_t id,
uint32_t userid) {
connector_ = connector;
initialize_name_ = name;
initialize_instance_id_ = id;
initialize_userid_ = userid;
Expand Down
34 changes: 29 additions & 5 deletions mojo/shell/public/cpp/shell_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@
#define MOJO_SHELL_PUBLIC_CPP_SHELL_TEST_H_

#include "base/memory/scoped_ptr.h"
#include "mojo/public/cpp/bindings/array.h"
#include "mojo/public/cpp/bindings/string.h"
#include "mojo/public/cpp/system/macros.h"
#include "mojo/shell/public/cpp/connector.h"
#include "mojo/shell/public/cpp/shell_client.h"
#include "mojo/shell/public/cpp/shell_connection.h"
#include "mojo/shell/public/interfaces/shell_client.mojom.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace base {
Expand All @@ -24,6 +22,29 @@ class BackgroundShell;
}
namespace test {

class ShellTest;

// A default implementation of ShellClient for use in ShellTests. Tests wishing
// to customize this should subclass this class instead of ShellClient,
// otherwise they will have to call ShellTest::InitializeCalled() to forward
// metadata from Initialize() to the test.
class ShellTestClient : public mojo::ShellClient {
public:
explicit ShellTestClient(ShellTest* test);
~ShellTestClient() override;

protected:
void Initialize(Connector* connector,
const std::string& name,
uint32_t id,
uint32_t user_id) override;

private:
ShellTest* test_;

DISALLOW_COPY_AND_ASSIGN(ShellTestClient);
};

class ShellTest : public testing::Test {
public:
ShellTest();
Expand Down Expand Up @@ -52,14 +73,17 @@ class ShellTest : public testing::Test {
virtual scoped_ptr<ShellClient> CreateShellClient();

// Call to set Initialize() metadata when GetShellClient() is overridden.
void InitializeCalled(const std::string& name, uint32_t id, uint32_t userid);
void InitializeCalled(Connector* connector,
const std::string& name,
uint32_t id,
uint32_t userid);

// testing::Test:
void SetUp() override;
void TearDown() override;

private:
class DefaultShellClient;
friend ShellTestClient;

scoped_ptr<ShellClient> shell_client_;

Expand Down
9 changes: 0 additions & 9 deletions mojo/shell/runner/host/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ group("host") {
]
}

config("native_application_support_with_gles2") {
defines = [ "NATIVE_APPLICATION_USE_GLES2_IMPL" ]
}

source_set("native_application_support") {
sources = [
"native_application_support.cc",
Expand All @@ -31,11 +27,6 @@ source_set("native_application_support") {
"//mojo/shell",
]

if (!is_mac) {
configs += [ ":native_application_support_with_gles2" ]
deps += [ "//mojo/gles2" ]
}

# This target has to include the public thunk headers, which generally
# shouldn't be included without picking an implementation. We are providing
# the implementation but the thunk header target cannot declare that we are
Expand Down
35 changes: 2 additions & 33 deletions mojo/shell/tests/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,18 @@ import("//testing/test.gni")
group("tests") {
testonly = true
deps = [
":apptests",
":mojo_shell_unittests",
]
}

source_set("test_support") {
testonly = true
sources = [
"capability_filter_test.cc",
"capability_filter_test.h",
]

deps = [
":interfaces",
"//mojo/shell",
"//mojo/shell/public/cpp",
"//mojo/shell/public/interfaces",
"//testing/gtest",
]
}

# TODO(beng): this target should just be called "unittests" but I am having
# difficulty with the android _apk generator.
test("mojo_shell_unittests") {
sources = [
"capability_filter_unittest.cc",
"loader_unittest.cc",
"run_all_unittests.cc",
"mojo_shell_unittests.cc",
]

deps = [
":interfaces",
":test_support",
"//base",
"//base/test:test_support",
"//mojo/edk/system",
Expand All @@ -52,25 +31,15 @@ test("mojo_shell_unittests") {
"//mojo/shell/background:main",
"//mojo/shell/background/tests:unittests",
"//mojo/shell/public/cpp",
"//mojo/shell/tests/application_manager",
"//mojo/shell/tests/connect",
"//mojo/util:filename_util",
"//testing/gtest",
"//url",
]
}

mojom("interfaces") {
sources = [
"capability_filter_unittest.mojom",
"test.mojom",
]
}

mojo_native_application("apptests") {
output_name = "mojo_shell_apptests"
testonly = true

deps = [
"//mojo/shell/tests/application_manager",
]
}
34 changes: 18 additions & 16 deletions mojo/shell/tests/application_manager/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import("//testing/test.gni")
source_set("application_manager") {
testonly = true
sources = [
"application_manager_apptest.cc",
"application_manager_unittest.cc",
]

deps = [
Expand All @@ -19,41 +19,39 @@ source_set("application_manager") {
"//base",
"//base/test:test_config",
"//mojo/common:common_base",
"//mojo/shell/public/cpp:shell_test_support",
"//mojo/shell/public/cpp:sources",
"//mojo/shell/public/cpp:test_support",
"//mojo/shell/public/interfaces",
]

data_deps = [
":application_manager_apptest_driver",
":application_manager_apptest_target",
":application_manager_unittest_driver",
":application_manager_unittest_target",
]
}

mojom("interfaces") {
sources = [
"application_manager_apptests.mojom",
"application_manager_unittest.mojom",
]
}

mojo_application_manifest("manifest") {
application_name = "mojo_shell_apptests"
source = "application_manager_apptest_manifest.json"
application_name = "application_manager_unittest"
source = "application_manager_unittest_manifest.json"
}

executable("application_manager_apptest_driver") {
executable("application_manager_unittest_driver") {
testonly = true

sources = [
"application_manager_apptest_driver.cc",
"driver.cc",
]

deps = [
":driver_manifest",
":interfaces",
"//base",
"//base:base_static",
"//build/config/sanitizers:deps",
"//mojo/common:common_base",
"//mojo/edk/system",
"//mojo/shell/public/cpp",
"//mojo/shell/public/interfaces",
Expand All @@ -63,18 +61,22 @@ executable("application_manager_apptest_driver") {
]
}

executable("application_manager_apptest_target") {
mojo_application_manifest("driver_manifest") {
type = "exe"
application_name = "application_manager_unittest_driver"
source = "driver_manifest.json"
}

executable("application_manager_unittest_target") {
testonly = true

sources = [
"application_manager_apptest_target.cc",
"target.cc",
]

deps = [
":interfaces",
"//base",
"//build/config/sanitizers:deps",
"//mojo/common:common_base",
"//mojo/shell/public/cpp",
"//mojo/shell/runner/child:test_native_main",
]
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 6a3bc7d

Please sign in to comment.