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

Side by Side Diff: mojo/shell/public/cpp/lib/shell_test.cc

Issue 1814983002: Convert filesystem_apptests to shelltests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: OK, filesystem_service_unittests works with modified ShellTest::SetUp(). Created 4 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 | « components/filesystem/test_manifest.json ('k') | mojo/shell/public/cpp/shell_test.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "mojo/shell/public/cpp/shell_test.h" 5 #include "mojo/shell/public/cpp/shell_test.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/run_loop.h"
8 #include "mojo/shell/background/background_shell.h" 9 #include "mojo/shell/background/background_shell.h"
9 #include "mojo/shell/public/cpp/shell_client.h" 10 #include "mojo/shell/public/cpp/shell_client.h"
10 11
11 namespace mojo { 12 namespace mojo {
12 namespace test { 13 namespace test {
13 14
14 ShellTestClient::ShellTestClient(ShellTest* test) : test_(test) {} 15 ShellTestClient::ShellTestClient(ShellTest* test) : test_(test) {}
15 ShellTestClient::~ShellTestClient() {} 16 ShellTestClient::~ShellTestClient() {}
16 17
17 void ShellTestClient::Initialize(Connector* connector, const Identity& identity, 18 void ShellTestClient::Initialize(Connector* connector, const Identity& identity,
(...skipping 19 matching lines...) Expand all
37 } 38 }
38 39
39 void ShellTest::InitializeCalled(Connector* connector, 40 void ShellTest::InitializeCalled(Connector* connector,
40 const std::string& name, 41 const std::string& name,
41 const std::string& user_id, 42 const std::string& user_id,
42 uint32_t id) { 43 uint32_t id) {
43 DCHECK_EQ(connector_, connector); 44 DCHECK_EQ(connector_, connector);
44 initialize_name_ = name; 45 initialize_name_ = name;
45 initialize_instance_id_ = id; 46 initialize_instance_id_ = id;
46 initialize_userid_ = user_id; 47 initialize_userid_ = user_id;
48 initialize_called_.Run();
47 } 49 }
48 50
49 void ShellTest::SetUp() { 51 void ShellTest::SetUp() {
50 shell_client_ = CreateShellClient(); 52 shell_client_ = CreateShellClient();
51 message_loop_ = CreateMessageLoop(); 53 message_loop_ = CreateMessageLoop();
52 background_shell_.reset(new shell::BackgroundShell); 54 background_shell_.reset(new shell::BackgroundShell);
53 background_shell_->Init(nullptr); 55 background_shell_->Init(nullptr);
56
57 // Create the shell connection. We don't proceed until we get our
58 // ShellClient's Initialize() method is called.
59 base::RunLoop run_loop;
yzshen1 2016/03/17 22:56:57 I am personally fine with this, but not sure wheth
60 base::MessageLoop::ScopedNestableTaskAllower allow(
61 base::MessageLoop::current());
62 initialize_called_ = run_loop.QuitClosure();
63
54 shell_connection_.reset(new ShellConnection( 64 shell_connection_.reset(new ShellConnection(
55 shell_client_.get(), 65 shell_client_.get(),
56 background_shell_->CreateShellClientRequest(test_name_))); 66 background_shell_->CreateShellClientRequest(test_name_)));
57 connector_ = shell_connection_->connector(); 67 connector_ = shell_connection_->connector();
68
69 run_loop.Run();
58 } 70 }
59 71
60 void ShellTest::TearDown() { 72 void ShellTest::TearDown() {
61 shell_connection_.reset(); 73 shell_connection_.reset();
62 background_shell_.reset(); 74 background_shell_.reset();
63 message_loop_.reset(); 75 message_loop_.reset();
64 shell_client_.reset(); 76 shell_client_.reset();
65 } 77 }
66 78
67 } // namespace test 79 } // namespace test
68 } // namespace mojo 80 } // namespace mojo
OLDNEW
« no previous file with comments | « components/filesystem/test_manifest.json ('k') | mojo/shell/public/cpp/shell_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698