Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 scoped_ptr<shell::BackgroundShell::InitParams> params( | |
| 55 new shell::BackgroundShell::InitParams); | |
| 56 background_shell_->Init(std::move(params)); | |
|
sky
2016/03/02 16:10:31
I'm pretty sure I made it so you can pass in null
| |
| 57 shell_connection_.reset(new ShellConnection( | |
| 58 shell_client_.get(), | |
| 59 background_shell_->CreateShellClientRequest(test_name_))); | |
| 60 shell_connection_->WaitForInitialize(); | |
| 61 } | |
| 62 | |
| 63 void ShellTest::TearDown() { | |
| 64 shell_connection_.reset(); | |
| 65 background_shell_.reset(); | |
| 66 message_loop_.reset(); | |
| 67 shell_client_.reset(); | |
| 68 } | |
| 69 | |
| 70 } // namespace test | |
| 71 } // namespace mojo | |
| OLD | NEW |