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

Side by Side Diff: shell/native_runner_unittest.cc

Issue 981733002: Rename {In,OutOf}ProcessDynamicServiceRunner -> ...NativeRunner. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: remove incorrect/flaky NOTREACHED() Created 5 years, 9 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 | « shell/launcher_main.cc ('k') | shell/out_of_process_dynamic_service_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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/files/scoped_temp_dir.h" 5 #include "base/files/scoped_temp_dir.h"
6 #include "shell/application_manager/application_manager.h" 6 #include "shell/application_manager/application_manager.h"
7 #include "shell/context.h" 7 #include "shell/context.h"
8 #include "shell/filename_util.h" 8 #include "shell/filename_util.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 namespace mojo { 11 namespace mojo {
12
13 namespace { 12 namespace {
14 13
15 struct TestState { 14 struct TestState {
16 TestState() 15 TestState()
17 : runner_was_created(false), 16 : runner_was_created(false),
18 runner_was_started(false), 17 runner_was_started(false),
19 runner_was_destroyed(false) {} 18 runner_was_destroyed(false) {}
20 19
21 bool runner_was_created; 20 bool runner_was_created;
22 bool runner_was_started; 21 bool runner_was_started;
(...skipping 25 matching lines...) Expand all
48 explicit TestNativeRunnerFactory(TestState* state) : state_(state) {} 47 explicit TestNativeRunnerFactory(TestState* state) : state_(state) {}
49 ~TestNativeRunnerFactory() override {} 48 ~TestNativeRunnerFactory() override {}
50 scoped_ptr<NativeRunner> Create(const Options& options) override { 49 scoped_ptr<NativeRunner> Create(const Options& options) override {
51 return scoped_ptr<NativeRunner>(new TestNativeRunner(state_)); 50 return scoped_ptr<NativeRunner>(new TestNativeRunner(state_));
52 } 51 }
53 52
54 private: 53 private:
55 TestState* state_; 54 TestState* state_;
56 }; 55 };
57 56
58 } // namespace
59
60 class NativeApplicationLoaderTest : public testing::Test, 57 class NativeApplicationLoaderTest : public testing::Test,
61 public ApplicationManager::Delegate { 58 public ApplicationManager::Delegate {
62 public: 59 public:
63 NativeApplicationLoaderTest() : application_manager_(this) {} 60 NativeApplicationLoaderTest() : application_manager_(this) {}
64 ~NativeApplicationLoaderTest() override {} 61 ~NativeApplicationLoaderTest() override {}
65 void SetUp() override { 62 void SetUp() override {
66 context_.Init(); 63 context_.Init();
67 scoped_ptr<NativeRunnerFactory> factory( 64 scoped_ptr<NativeRunnerFactory> factory(
68 new TestNativeRunnerFactory(&state_)); 65 new TestNativeRunnerFactory(&state_));
69 application_manager_.set_native_runner_factory(factory.Pass()); 66 application_manager_.set_native_runner_factory(factory.Pass());
70 application_manager_.set_blocking_pool( 67 application_manager_.set_blocking_pool(
71 context_.task_runners()->blocking_pool()); 68 context_.task_runners()->blocking_pool());
72 } 69 }
73 void TearDown() override { context_.Shutdown(); } 70 void TearDown() override { context_.Shutdown(); }
74 71
75 protected: 72 protected:
76 shell::Context context_; 73 shell::Context context_;
77 base::MessageLoop loop_; 74 base::MessageLoop loop_;
78 ApplicationManager application_manager_; 75 ApplicationManager application_manager_;
79 TestState state_; 76 TestState state_;
80 77
81 private: 78 private:
82 // ApplicationManager::Delegate 79 // ApplicationManager::Delegate
83 void OnApplicationError(const GURL& url) override { NOTREACHED(); } 80 void OnApplicationError(const GURL& url) override {}
84 81
85 GURL ResolveURL(const GURL& url) override { return url; } 82 GURL ResolveURL(const GURL& url) override { return url; }
86 83
87 GURL ResolveMappings(const GURL& url) override { return url; } 84 GURL ResolveMappings(const GURL& url) override { return url; }
88 }; 85 };
89 86
90 TEST_F(NativeApplicationLoaderTest, DoesNotExist) { 87 TEST_F(NativeApplicationLoaderTest, DoesNotExist) {
91 base::ScopedTempDir temp_dir; 88 base::ScopedTempDir temp_dir;
92 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 89 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
93 base::FilePath nonexistent_file(FILE_PATH_LITERAL("nonexistent.txt")); 90 base::FilePath nonexistent_file(FILE_PATH_LITERAL("nonexistent.txt"));
94 GURL url(FilePathToFileURL(temp_dir.path().Append(nonexistent_file))); 91 GURL url(FilePathToFileURL(temp_dir.path().Append(nonexistent_file)));
95 InterfaceRequest<ServiceProvider> services; 92 InterfaceRequest<ServiceProvider> services;
96 ServiceProviderPtr service_provider; 93 ServiceProviderPtr service_provider;
97 application_manager_.ConnectToApplication(url, GURL(), services.Pass(), 94 application_manager_.ConnectToApplication(url, GURL(), services.Pass(),
98 service_provider.Pass()); 95 service_provider.Pass());
99 EXPECT_FALSE(state_.runner_was_created); 96 EXPECT_FALSE(state_.runner_was_created);
100 EXPECT_FALSE(state_.runner_was_started); 97 EXPECT_FALSE(state_.runner_was_started);
101 EXPECT_FALSE(state_.runner_was_destroyed); 98 EXPECT_FALSE(state_.runner_was_destroyed);
102 } 99 }
103 100
101 } // namespace
104 } // namespace mojo 102 } // namespace mojo
OLDNEW
« no previous file with comments | « shell/launcher_main.cc ('k') | shell/out_of_process_dynamic_service_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698