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

Side by Side Diff: mojo/shell/capability_filter_test.h

Issue 1358533004: Move more of ContentHandler handling into PackageManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 2 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/application_manager_unittest.cc ('k') | mojo/shell/capability_filter_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
(Empty)
1 // Copyright 2015 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 "base/at_exit.h"
6 #include "base/bind.h"
7 #include "base/macros.h"
8 #include "base/message_loop/message_loop.h"
9 #include "mojo/application/public/cpp/application_delegate.h"
10 #include "mojo/shell/application_loader.h"
11 #include "mojo/shell/application_manager.h"
12 #include "mojo/shell/capability_filter_unittest.mojom.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14
15 namespace mojo {
16 namespace shell {
17 namespace test {
18
19 class ConnectionValidator;
20
21 // This class models an application who will use the shell to interact with a
22 // system service. The shell may limit this application's visibility of the full
23 // set of interfaces exposed by that service.
24 class TestApplication : public ApplicationDelegate {
25 public:
26 TestApplication();
27 ~TestApplication() override;
28
29 private:
30 // Overridden from ApplicationDelegate:
31 void Initialize(ApplicationImpl* app) override;
32 bool ConfigureIncomingConnection(ApplicationConnection* connection) override;
33
34 void ConnectionClosed(const std::string& service_url);
35
36 ApplicationImpl* app_;
37 ValidatorPtr validator_;
38 scoped_ptr<ApplicationConnection> connection1_;
39 scoped_ptr<ApplicationConnection> connection2_;
40
41 DISALLOW_COPY_AND_ASSIGN(TestApplication);
42 };
43
44 class TestLoader : public ApplicationLoader {
45 public:
46 explicit TestLoader(ApplicationDelegate* delegate);
47 ~TestLoader() override;
48
49 private:
50 // Overridden from ApplicationLoader:
51 void Load(const GURL& url, InterfaceRequest<Application> request) override;
52
53 scoped_ptr<ApplicationDelegate> delegate_;
54 scoped_ptr<ApplicationImpl> app_;
55
56 DISALLOW_COPY_AND_ASSIGN(TestLoader);
57 };
58
59 class CapabilityFilterTest : public testing::Test {
60 public:
61 CapabilityFilterTest();
62 ~CapabilityFilterTest() override;
63
64 protected:
65 template <class T>
66 void CreateLoader(const std::string& url) {
67 application_manager_->SetLoaderForURL(
68 make_scoped_ptr(new TestLoader(new T)), GURL(url));
69 }
70
71 void RunBlockingTest();
72 void RunWildcardTest();
73
74 // Implement to provide an implementation of PackageManager for the test's
75 // ApplicationManager.
76 virtual PackageManager* CreatePackageManager() = 0;
77
78 // Overridden from testing::Test:
79 void SetUp() override;
80 void TearDown() override;
81
82 base::MessageLoop* loop() { return &loop_; }
83 ApplicationManager* application_manager() {
84 return application_manager_.get();
85 }
86 ConnectionValidator* validator() { return validator_; }
87
88 private:
89 void RunApplication(const std::string& url, const CapabilityFilter& filter);
90 void InitValidator(const std::set<std::string>& expectations);
91 void RunTest();
92
93 template<class T>
94 scoped_ptr<ApplicationDelegate> CreateApplicationDelegate() {
95 return scoped_ptr<ApplicationDelegate>(new T);
96 }
97
98 base::ShadowingAtExitManager at_exit_;
99 base::MessageLoop loop_;
100 scoped_ptr<ApplicationManager> application_manager_;
101 ConnectionValidator* validator_;
102
103 DISALLOW_COPY_AND_ASSIGN(CapabilityFilterTest);
104 };
105
106 } // namespace test
107 } // namespace shell
108 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/application_manager_unittest.cc ('k') | mojo/shell/capability_filter_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698