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

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

Issue 420143003: mojo: shell::Context should outlive the shell MessageLoop (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix + verify android 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_service_loader.h" 7 #include "mojo/shell/dynamic_service_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"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 TestState* state_; 48 TestState* state_;
49 }; 49 };
50 50
51 } // namespace 51 } // namespace
52 52
53 class DynamicServiceLoaderTest : public testing::Test { 53 class DynamicServiceLoaderTest : public testing::Test {
54 public: 54 public:
55 DynamicServiceLoaderTest() {} 55 DynamicServiceLoaderTest() {}
56 virtual ~DynamicServiceLoaderTest() {} 56 virtual ~DynamicServiceLoaderTest() {}
57 virtual void SetUp() OVERRIDE { 57 virtual void SetUp() OVERRIDE {
58 context_.Init();
58 scoped_ptr<DynamicServiceRunnerFactory> factory( 59 scoped_ptr<DynamicServiceRunnerFactory> factory(
59 new TestDynamicServiceRunnerFactory(&state_)); 60 new TestDynamicServiceRunnerFactory(&state_));
60 loader_.reset(new DynamicServiceLoader(&context_, factory.Pass())); 61 loader_.reset(new DynamicServiceLoader(&context_, factory.Pass()));
61 } 62 }
62 protected: 63 protected:
64 Context context_;
63 base::MessageLoop loop_; 65 base::MessageLoop loop_;
64 Context context_;
65 scoped_ptr<DynamicServiceLoader> loader_; 66 scoped_ptr<DynamicServiceLoader> loader_;
66 TestState state_; 67 TestState state_;
67 }; 68 };
68 69
69 TEST_F(DynamicServiceLoaderTest, DoesNotExist) { 70 TEST_F(DynamicServiceLoaderTest, DoesNotExist) {
70 base::ScopedTempDir temp_dir; 71 base::ScopedTempDir temp_dir;
71 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 72 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
72 base::FilePath nonexistent_file(FILE_PATH_LITERAL("nonexistent.txt")); 73 base::FilePath nonexistent_file(FILE_PATH_LITERAL("nonexistent.txt"));
73 GURL url(net::FilePathToFileURL(temp_dir.path().Append(nonexistent_file))); 74 GURL url(net::FilePathToFileURL(temp_dir.path().Append(nonexistent_file)));
74 MessagePipe pipe; 75 MessagePipe pipe;
75 loader_->LoadService(context_.service_manager(), url, pipe.handle0.Pass()); 76 loader_->LoadService(context_.service_manager(), url, pipe.handle0.Pass());
76 loop_.Run(); 77 loop_.Run();
77 EXPECT_FALSE(state_.runner_was_started); 78 EXPECT_FALSE(state_.runner_was_started);
78 EXPECT_TRUE(state_.runner_was_destroyed); 79 EXPECT_TRUE(state_.runner_was_destroyed);
79 } 80 }
80 81
81 } // namespace shell 82 } // namespace shell
82 } // namespace mojo 83 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/desktop/mojo_main.cc ('k') | mojo/shell/in_process_dynamic_service_runner_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698