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

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

Issue 491443005: Get rid of KeepAlive. Quit shell when all urls run directly by Context are closed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Bring back ConnectToServiceViaNetwork Created 6 years, 4 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 | Annotate | Revision Log
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 "mojo/shell/context.h" 6 #include "mojo/shell/context.h"
7 #include "mojo/shell/dynamic_application_loader.h" 7 #include "mojo/shell/dynamic_application_loader.h"
8 #include "mojo/shell/dynamic_service_runner.h" 8 #include "mojo/shell/dynamic_service_runner.h"
9 #include "net/base/filename_util.h" 9 #include "net/base/filename_util.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 namespace mojo { 12 namespace mojo {
13 namespace shell { 13 namespace shell {
14 14
15 namespace { 15 namespace {
16 16
17 struct TestState { 17 struct TestState {
18 TestState() : runner_was_started(false), runner_was_destroyed(false) {} 18 TestState()
19 : runner_was_created(false),
20 runner_was_started(false),
21 runner_was_destroyed(false) {}
22
23 bool runner_was_created;
19 bool runner_was_started; 24 bool runner_was_started;
20 bool runner_was_destroyed; 25 bool runner_was_destroyed;
21 }; 26 };
22 27
23 class TestDynamicServiceRunner : public DynamicServiceRunner { 28 class TestDynamicServiceRunner : public DynamicServiceRunner {
24 public: 29 public:
25 explicit TestDynamicServiceRunner(TestState* state) : state_(state) {} 30 explicit TestDynamicServiceRunner(TestState* state) : state_(state) {
31 state_->runner_was_created = true;
32 }
26 virtual ~TestDynamicServiceRunner() { 33 virtual ~TestDynamicServiceRunner() {
27 state_->runner_was_destroyed = true; 34 state_->runner_was_destroyed = true;
28 base::MessageLoop::current()->Quit(); 35 base::MessageLoop::current()->Quit();
29 } 36 }
30 virtual void Start(const base::FilePath& app_path, 37 virtual void Start(const base::FilePath& app_path,
31 ScopedMessagePipeHandle service_handle, 38 ScopedMessagePipeHandle service_handle,
32 const base::Closure& app_completed_callback) OVERRIDE { 39 const base::Closure& app_completed_callback) OVERRIDE {
33 state_->runner_was_started = true; 40 state_->runner_was_started = true;
34 } 41 }
35 42
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 79
73 TEST_F(DynamicApplicationLoaderTest, DoesNotExist) { 80 TEST_F(DynamicApplicationLoaderTest, DoesNotExist) {
74 base::ScopedTempDir temp_dir; 81 base::ScopedTempDir temp_dir;
75 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 82 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
76 base::FilePath nonexistent_file(FILE_PATH_LITERAL("nonexistent.txt")); 83 base::FilePath nonexistent_file(FILE_PATH_LITERAL("nonexistent.txt"));
77 GURL url(net::FilePathToFileURL(temp_dir.path().Append(nonexistent_file))); 84 GURL url(net::FilePathToFileURL(temp_dir.path().Append(nonexistent_file)));
78 MessagePipe pipe; 85 MessagePipe pipe;
79 scoped_refptr<ApplicationLoader::SimpleLoadCallbacks> callbacks( 86 scoped_refptr<ApplicationLoader::SimpleLoadCallbacks> callbacks(
80 new ApplicationLoader::SimpleLoadCallbacks(pipe.handle0.Pass())); 87 new ApplicationLoader::SimpleLoadCallbacks(pipe.handle0.Pass()));
81 loader_->Load(context_.application_manager(), url, callbacks); 88 loader_->Load(context_.application_manager(), url, callbacks);
82 loop_.Run(); 89 EXPECT_FALSE(state_.runner_was_created);
83 EXPECT_FALSE(state_.runner_was_started); 90 EXPECT_FALSE(state_.runner_was_started);
84 EXPECT_TRUE(state_.runner_was_destroyed); 91 EXPECT_FALSE(state_.runner_was_destroyed);
85 } 92 }
86 93
87 } // namespace shell 94 } // namespace shell
88 } // namespace mojo 95 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698