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

Side by Side Diff: shell/shell_test_base.h

Issue 815993004: Run shell tests on android. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: move shell_test_base_android.cc Created 6 years 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef SHELL_SHELL_TEST_BASE_H_ 5 #ifndef SHELL_SHELL_TEST_BASE_H_
6 #define SHELL_SHELL_TEST_BASE_H_ 6 #define SHELL_SHELL_TEST_BASE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/files/file_path.h"
viettrungluu 2014/12/19 18:31:34 I don't think you need this....
qsr 2014/12/22 10:52:32 Done.
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
12 #include "mojo/public/cpp/system/core.h" 13 #include "mojo/public/cpp/system/core.h"
13 #include "shell/context.h" 14 #include "shell/context.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 16
16 class GURL; 17 class GURL;
17 18
18 namespace mojo { 19 namespace mojo {
19 namespace shell { 20 namespace shell {
20 namespace test { 21 namespace test {
21 22
22 class ShellTestBase : public testing::Test { 23 class ShellTestBase : public testing::Test {
23 public: 24 public:
24 ShellTestBase(); 25 ShellTestBase();
25 ~ShellTestBase() override; 26 ~ShellTestBase() override;
26 27
27 void SetUp() override; 28 void SetUp() override;
28 29
29 // |application_url| should typically be a mojo: URL (the origin will be set 30 // |application_url| should typically be a mojo: URL (the origin will be set
30 // to an "appropriate" file: URL). 31 // to an "appropriate" file: URL).
31 // TODO(tim): Should the test base be a ServiceProvider? 32 // TODO(tim): Should the test base be a ServiceProvider?
32 ScopedMessagePipeHandle ConnectToService(const GURL& application_url, 33 ScopedMessagePipeHandle ConnectToService(const GURL& application_url,
33 const std::string& service_name); 34 const std::string& service_name);
34 35
35 ScopedMessagePipeHandle ConnectToServiceViaNetwork(
36 const GURL& application_url,
37 const std::string& service_name);
38
39 template <typename Interface> 36 template <typename Interface>
40 void ConnectToService(const GURL& application_url, 37 void ConnectToService(const GURL& application_url,
41 InterfacePtr<Interface>* ptr) { 38 InterfacePtr<Interface>* ptr) {
42 ptr->Bind(ConnectToService(application_url, Interface::Name_).Pass()); 39 ptr->Bind(ConnectToService(application_url, Interface::Name_).Pass());
43 } 40 }
44 41
45 template <typename Interface>
46 void ConnectToServiceViaNetwork(const GURL& application_url,
47 InterfacePtr<Interface>* ptr) {
48 ptr->Bind(
49 ConnectToServiceViaNetwork(application_url, Interface::Name_).Pass());
50 }
51
52 base::MessageLoop* message_loop() { return &message_loop_; } 42 base::MessageLoop* message_loop() { return &message_loop_; }
53 Context* shell_context() { return &shell_context_; } 43 Context* shell_context() { return &shell_context_; }
54 44
55 private: 45 private:
46 // Set up the test applications so that mojo: URL resolves to those.
47 void SetUpTestApplications();
48
56 Context shell_context_; 49 Context shell_context_;
57 base::MessageLoop message_loop_; 50 base::MessageLoop message_loop_;
58 51
59 DISALLOW_COPY_AND_ASSIGN(ShellTestBase); 52 DISALLOW_COPY_AND_ASSIGN(ShellTestBase);
60 }; 53 };
61 54
62 } // namespace test 55 } // namespace test
63 } // namespace shell 56 } // namespace shell
64 } // namespace mojo 57 } // namespace mojo
65 58
66 #endif // SHELL_SHELL_TEST_BASE_H_ 59 #endif // SHELL_SHELL_TEST_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698