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

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

Issue 1758633002: Convert Connect apptest to a unittest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@25tests
Patch Set: . 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 | « mojo/shell/public/cpp/BUILD.gn ('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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "mojo/shell/public/cpp/shell_test.h"
6
7 #include "base/message_loop/message_loop.h"
8 #include "mojo/shell/background/background_shell.h"
9 #include "mojo/shell/public/cpp/shell_client.h"
10
11 namespace mojo {
12 namespace test {
13 class ShellTest::DefaultShellClient : public ShellClient {
14 public:
15 explicit DefaultShellClient(ShellTest* test) : test_(test) {}
16 ~DefaultShellClient() override {}
17
18 private:
19 void Initialize(Connector* connector, const std::string& name,
20 uint32_t id, uint32_t user_id /* = 0 */) override {
21 test_->connector_ = connector;
22 test_->InitializeCalled(name, id, user_id);
23 }
24
25 ShellTest* test_;
26
27 DISALLOW_COPY_AND_ASSIGN(DefaultShellClient);
28 };
29
30 ShellTest::ShellTest() {}
31 ShellTest::ShellTest(const std::string& test_name) : test_name_(test_name) {}
32 ShellTest::~ShellTest() {}
33
34 void ShellTest::InitTestName(const std::string& test_name) {
35 DCHECK(test_name_.empty());
36 test_name_ = test_name;
37 }
38
39 scoped_ptr<ShellClient> ShellTest::CreateShellClient() {
40 return make_scoped_ptr(new DefaultShellClient(this));
41 }
42
43 void ShellTest::InitializeCalled(const std::string& name, uint32_t id,
44 uint32_t userid) {
45 initialize_name_ = name;
46 initialize_instance_id_ = id;
47 initialize_userid_ = userid;
48 }
49
50 void ShellTest::SetUp() {
51 shell_client_ = CreateShellClient();
52 message_loop_.reset(new base::MessageLoop);
53 background_shell_.reset(new shell::BackgroundShell);
54 background_shell_->Init(nullptr);
55 shell_connection_.reset(new ShellConnection(
56 shell_client_.get(),
57 background_shell_->CreateShellClientRequest(test_name_)));
58 shell_connection_->WaitForInitialize();
59 }
60
61 void ShellTest::TearDown() {
62 shell_connection_.reset();
63 background_shell_.reset();
64 message_loop_.reset();
65 shell_client_.reset();
66 }
67
68 } // namespace test
69 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/public/cpp/BUILD.gn ('k') | mojo/shell/public/cpp/shell_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698