Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Side by Side Diff: mojo/shell/native_runner_unittest.cc

Issue 1049993002: Get mojo_shell building inside chromium checkout. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix presubmit Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/shell/native_application_support.cc ('k') | mojo/shell/out_of_process_native_runner.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/files/scoped_temp_dir.h"
6 #include "mojo/shell/application_manager/application_manager.h"
7 #include "mojo/shell/context.h"
8 #include "mojo/shell/filename_util.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 namespace mojo {
12 namespace shell {
13 namespace {
14
15 struct TestState {
16 TestState()
17 : runner_was_created(false),
18 runner_was_started(false),
19 runner_was_destroyed(false) {}
20
21 bool runner_was_created;
22 bool runner_was_started;
23 bool runner_was_destroyed;
24 };
25
26 class TestNativeRunner : public NativeRunner {
27 public:
28 explicit TestNativeRunner(TestState* state) : state_(state) {
29 state_->runner_was_created = true;
30 }
31 ~TestNativeRunner() override {
32 state_->runner_was_destroyed = true;
33 base::MessageLoop::current()->Quit();
34 }
35 void Start(const base::FilePath& app_path,
36 NativeApplicationCleanup cleanup,
37 InterfaceRequest<Application> application_request,
38 const base::Closure& app_completed_callback) override {
39 state_->runner_was_started = true;
40 }
41
42 private:
43 TestState* state_;
44 };
45
46 class TestNativeRunnerFactory : public NativeRunnerFactory {
47 public:
48 explicit TestNativeRunnerFactory(TestState* state) : state_(state) {}
49 ~TestNativeRunnerFactory() override {}
50 scoped_ptr<NativeRunner> Create(const Options& options) override {
51 return scoped_ptr<NativeRunner>(new TestNativeRunner(state_));
52 }
53
54 private:
55 TestState* state_;
56 };
57
58 class NativeApplicationLoaderTest : public testing::Test,
59 public ApplicationManager::Delegate {
60 public:
61 NativeApplicationLoaderTest() : application_manager_(this) {}
62 ~NativeApplicationLoaderTest() override {}
63 void SetUp() override {
64 context_.Init();
65 scoped_ptr<NativeRunnerFactory> factory(
66 new TestNativeRunnerFactory(&state_));
67 application_manager_.set_native_runner_factory(factory.Pass());
68 application_manager_.set_blocking_pool(
69 context_.task_runners()->blocking_pool());
70 }
71 void TearDown() override { context_.Shutdown(); }
72
73 protected:
74 shell::Context context_;
75 base::MessageLoop loop_;
76 ApplicationManager application_manager_;
77 TestState state_;
78
79 private:
80 // ApplicationManager::Delegate
81 GURL ResolveURL(const GURL& url) override { return url; }
82
83 GURL ResolveMappings(const GURL& url) override { return url; }
84 };
85
86 TEST_F(NativeApplicationLoaderTest, DoesNotExist) {
87 base::ScopedTempDir temp_dir;
88 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
89 base::FilePath nonexistent_file(FILE_PATH_LITERAL("nonexistent.txt"));
90 GURL url(FilePathToFileURL(temp_dir.path().Append(nonexistent_file)));
91 InterfaceRequest<ServiceProvider> services;
92 ServiceProviderPtr service_provider;
93 application_manager_.ConnectToApplication(
94 url, GURL(), services.Pass(), service_provider.Pass(), base::Closure());
95 EXPECT_FALSE(state_.runner_was_created);
96 EXPECT_FALSE(state_.runner_was_started);
97 EXPECT_FALSE(state_.runner_was_destroyed);
98 }
99
100 } // namespace
101 } // namespace shell
102 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/native_application_support.cc ('k') | mojo/shell/out_of_process_native_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698