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

Side by Side Diff: services/shell/public/cpp/lib/service_test.cc

Issue 2123363002: ShellTest -> ServiceTest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 5 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 | « services/shell/public/cpp/BUILD.gn ('k') | services/shell/public/cpp/lib/shell_test.cc » ('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 "services/shell/public/cpp/shell_test.h" 5 #include "services/shell/public/cpp/service_test.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "services/shell/background/background_shell.h" 10 #include "services/shell/background/background_shell.h"
11 #include "services/shell/public/cpp/service.h" 11 #include "services/shell/public/cpp/service.h"
12 12
13 namespace shell { 13 namespace shell {
14 namespace test { 14 namespace test {
15 15
16 ShellTestClient::ShellTestClient(ShellTest* test) : test_(test) {} 16 ServiceTestClient::ServiceTestClient(ServiceTest* test) : test_(test) {}
17 ShellTestClient::~ShellTestClient() {} 17 ServiceTestClient::~ServiceTestClient() {}
18 18
19 void ShellTestClient::OnStart(Connector* connector, const Identity& identity, 19 void ServiceTestClient::OnStart(Connector* connector, const Identity& identity,
20 uint32_t id) { 20 uint32_t id) {
21 test_->OnStartCalled(connector, identity.name(), identity.user_id(), id); 21 test_->OnStartCalled(connector, identity.name(), identity.user_id(), id);
22 } 22 }
23 23
24 ShellTest::ShellTest() {} 24 ServiceTest::ServiceTest() {}
25 ShellTest::ShellTest(const std::string& test_name) : test_name_(test_name) {} 25 ServiceTest::ServiceTest(const std::string& test_name)
26 ShellTest::~ShellTest() {} 26 : test_name_(test_name) {}
27 ServiceTest::~ServiceTest() {}
27 28
28 void ShellTest::InitTestName(const std::string& test_name) { 29 void ServiceTest::InitTestName(const std::string& test_name) {
29 DCHECK(test_name_.empty()); 30 DCHECK(test_name_.empty());
30 test_name_ = test_name; 31 test_name_ = test_name;
31 } 32 }
32 33
33 std::unique_ptr<Service> ShellTest::CreateService() { 34 std::unique_ptr<Service> ServiceTest::CreateService() {
34 return base::WrapUnique(new ShellTestClient(this)); 35 return base::WrapUnique(new ServiceTestClient(this));
35 } 36 }
36 37
37 std::unique_ptr<base::MessageLoop> ShellTest::CreateMessageLoop() { 38 std::unique_ptr<base::MessageLoop> ServiceTest::CreateMessageLoop() {
38 return base::WrapUnique(new base::MessageLoop); 39 return base::WrapUnique(new base::MessageLoop);
39 } 40 }
40 41
41 void ShellTest::OnStartCalled(Connector* connector, 42 void ServiceTest::OnStartCalled(Connector* connector,
42 const std::string& name, 43 const std::string& name,
43 const std::string& user_id, 44 const std::string& user_id,
44 uint32_t id) { 45 uint32_t id) {
45 DCHECK_EQ(connector_, connector); 46 DCHECK_EQ(connector_, connector);
46 initialize_name_ = name; 47 initialize_name_ = name;
47 initialize_instance_id_ = id; 48 initialize_instance_id_ = id;
48 initialize_userid_ = user_id; 49 initialize_userid_ = user_id;
49 initialize_called_.Run(); 50 initialize_called_.Run();
50 } 51 }
51 52
52 void ShellTest::SetUp() { 53 void ServiceTest::SetUp() {
53 service_ = CreateService(); 54 service_ = CreateService();
54 message_loop_ = CreateMessageLoop(); 55 message_loop_ = CreateMessageLoop();
55 background_shell_.reset(new shell::BackgroundShell); 56 background_shell_.reset(new shell::BackgroundShell);
56 background_shell_->Init(nullptr); 57 background_shell_->Init(nullptr);
57 58
58 // Create the shell connection. We don't proceed until we get our 59 // Create the shell connection. We don't proceed until we get our
59 // Service's OnStart() method is called. 60 // Service's OnStart() method is called.
60 base::RunLoop run_loop; 61 base::RunLoop run_loop;
61 base::MessageLoop::ScopedNestableTaskAllower allow( 62 base::MessageLoop::ScopedNestableTaskAllower allow(
62 base::MessageLoop::current()); 63 base::MessageLoop::current());
63 initialize_called_ = run_loop.QuitClosure(); 64 initialize_called_ = run_loop.QuitClosure();
64 65
65 shell_connection_.reset(new ShellConnection( 66 shell_connection_.reset(new ShellConnection(
66 service_.get(), 67 service_.get(),
67 background_shell_->CreateServiceRequest(test_name_))); 68 background_shell_->CreateServiceRequest(test_name_)));
68 connector_ = shell_connection_->connector(); 69 connector_ = shell_connection_->connector();
69 70
70 run_loop.Run(); 71 run_loop.Run();
71 } 72 }
72 73
73 void ShellTest::TearDown() { 74 void ServiceTest::TearDown() {
74 shell_connection_.reset(); 75 shell_connection_.reset();
75 background_shell_.reset(); 76 background_shell_.reset();
76 message_loop_.reset(); 77 message_loop_.reset();
77 service_.reset(); 78 service_.reset();
78 } 79 }
79 80
80 } // namespace test 81 } // namespace test
81 } // namespace shell 82 } // namespace shell
OLDNEW
« no previous file with comments | « services/shell/public/cpp/BUILD.gn ('k') | services/shell/public/cpp/lib/shell_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698