| OLD | NEW |
| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/memory/ptr_util.h" | 6 #include "base/memory/ptr_util.h" |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "services/shell/background/background_shell.h" | 8 #include "services/shell/background/background_shell.h" |
| 9 #include "services/shell/background/tests/test_catalog_store.h" | 9 #include "services/shell/background/tests/test_catalog_store.h" |
| 10 #include "services/shell/public/cpp/connector.h" | 10 #include "services/shell/public/cpp/connector.h" |
| 11 #include "services/shell/public/cpp/shell_client.h" | 11 #include "services/shell/public/cpp/shell_client.h" |
| 12 #include "services/shell/public/cpp/shell_connection.h" | 12 #include "services/shell/public/cpp/shell_connection.h" |
| 13 #include "ui/aura/env.h" | 13 #include "ui/aura/env.h" |
| 14 #include "ui/views/mus/window_manager_connection.h" | 14 #include "ui/views/mus/window_manager_connection.h" |
| 15 #include "ui/views/test/platform_test_helper.h" | 15 #include "ui/views/test/platform_test_helper.h" |
| 16 #include "ui/views/views_delegate.h" | 16 #include "ui/views/views_delegate.h" |
| 17 | 17 |
| 18 using shell::BackgroundShell; | 18 using shell::BackgroundShell; |
| 19 | 19 |
| 20 namespace views { | 20 namespace views { |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 const char kTestName[] = "exe:views_mus_unittests"; | 23 const char kTestName[] = "mojo:test-app"; |
| 24 | 24 |
| 25 class DefaultShellClient : public shell::ShellClient { | 25 class DefaultShellClient : public shell::ShellClient { |
| 26 public: | 26 public: |
| 27 DefaultShellClient() {} | 27 DefaultShellClient() {} |
| 28 ~DefaultShellClient() override {} | 28 ~DefaultShellClient() override {} |
| 29 | 29 |
| 30 private: | 30 private: |
| 31 DISALLOW_COPY_AND_ASSIGN(DefaultShellClient); | 31 DISALLOW_COPY_AND_ASSIGN(DefaultShellClient); |
| 32 }; | 32 }; |
| 33 | 33 |
| 34 std::unique_ptr<shell::TestCatalogStore> BuildTestCatalogStore() { |
| 35 std::unique_ptr<base::ListValue> apps(new base::ListValue); |
| 36 apps->Append(shell::BuildPermissiveSerializedAppInfo(kTestName, "test")); |
| 37 return base::WrapUnique(new shell::TestCatalogStore(std::move(apps))); |
| 38 } |
| 39 |
| 34 class PlatformTestHelperMus : public PlatformTestHelper { | 40 class PlatformTestHelperMus : public PlatformTestHelper { |
| 35 public: | 41 public: |
| 36 PlatformTestHelperMus() { | 42 PlatformTestHelperMus() { |
| 37 background_shell_.reset(new BackgroundShell); | 43 background_shell_.reset(new BackgroundShell); |
| 38 background_shell_->Init(nullptr); | 44 std::unique_ptr<BackgroundShell::InitParams> init_params( |
| 45 new BackgroundShell::InitParams); |
| 46 init_params->catalog_store = BuildTestCatalogStore(); |
| 47 background_shell_->Init(std::move(init_params)); |
| 39 shell_client_.reset(new DefaultShellClient); | 48 shell_client_.reset(new DefaultShellClient); |
| 40 shell_connection_.reset(new shell::ShellConnection( | 49 shell_connection_.reset(new shell::ShellConnection( |
| 41 shell_client_.get(), | 50 shell_client_.get(), |
| 42 background_shell_->CreateShellClientRequest(kTestName))); | 51 background_shell_->CreateShellClientRequest(kTestName))); |
| 43 | 52 |
| 44 // TODO(rockot): Remove this RunLoop. http://crbug.com/594852. | 53 // TODO(rockot): Remove this RunLoop. http://crbug.com/594852. |
| 45 base::RunLoop wait_loop; | 54 base::RunLoop wait_loop; |
| 46 shell_connection_->set_initialize_handler(wait_loop.QuitClosure()); | 55 shell_connection_->set_initialize_handler(wait_loop.QuitClosure()); |
| 47 wait_loop.Run(); | 56 wait_loop.Run(); |
| 48 | 57 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 }; | 99 }; |
| 91 | 100 |
| 92 } // namespace | 101 } // namespace |
| 93 | 102 |
| 94 // static | 103 // static |
| 95 std::unique_ptr<PlatformTestHelper> PlatformTestHelper::Create() { | 104 std::unique_ptr<PlatformTestHelper> PlatformTestHelper::Create() { |
| 96 return base::WrapUnique(new PlatformTestHelperMus); | 105 return base::WrapUnique(new PlatformTestHelperMus); |
| 97 } | 106 } |
| 98 | 107 |
| 99 } // namespace views | 108 } // namespace views |
| OLD | NEW |