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

Side by Side Diff: shell/shell_test_base_unittest.cc

Issue 775343004: Move //mojo/shell to //shell (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: 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
« no previous file with comments | « shell/shell_test_base.cc ('k') | shell/shell_test_helper.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "mojo/shell/shell_test_base.h" 5 #include "shell/shell_test_base.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/i18n/time_formatting.h" 8 #include "base/i18n/time_formatting.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "mojo/public/cpp/bindings/error_handler.h" 12 #include "mojo/public/cpp/bindings/error_handler.h"
13 #include "mojo/public/cpp/bindings/interface_ptr.h" 13 #include "mojo/public/cpp/bindings/interface_ptr.h"
14 #include "mojo/public/cpp/system/core.h" 14 #include "mojo/public/cpp/system/core.h"
15 #include "services/test_service/test_request_tracker.mojom.h" 15 #include "services/test_service/test_request_tracker.mojom.h"
(...skipping 22 matching lines...) Expand all
38 reports_out->push_back(*report[i]); 38 reports_out->push_back(*report[i]);
39 loop->QuitWhenIdle(); 39 loop->QuitWhenIdle();
40 } 40 }
41 41
42 class ShellTestBaseTest : public ShellTestBase { 42 class ShellTestBaseTest : public ShellTestBase {
43 public: 43 public:
44 // Convenience helpers for use as callbacks in tests. 44 // Convenience helpers for use as callbacks in tests.
45 template <typename T> 45 template <typename T>
46 base::Callback<void()> SetAndQuit(T* val, T result) { 46 base::Callback<void()> SetAndQuit(T* val, T result) {
47 return base::Bind(&ShellTestBaseTest::SetAndQuitImpl<T>, 47 return base::Bind(&ShellTestBaseTest::SetAndQuitImpl<T>,
48 base::Unretained(this), val, result); 48 base::Unretained(this), val, result);
49 } 49 }
50 template <typename T> 50 template <typename T>
51 base::Callback<void(T result)> SetAndQuit(T* val) { 51 base::Callback<void(T result)> SetAndQuit(T* val) {
52 return base::Bind(&ShellTestBaseTest::SetAndQuitImpl<T>, 52 return base::Bind(&ShellTestBaseTest::SetAndQuitImpl<T>,
53 base::Unretained(this), val); 53 base::Unretained(this), val);
54 } 54 }
55 static GURL test_app_url() { return GURL("mojo:test_app"); } 55 static GURL test_app_url() { return GURL("mojo:test_app"); }
56 56
57 void GetReport(std::vector<ServiceReport>* report) { 57 void GetReport(std::vector<ServiceReport>* report) {
58 ConnectToService(GURL("mojo:test_request_tracker_app"), &request_tracking_); 58 ConnectToService(GURL("mojo:test_request_tracker_app"), &request_tracking_);
59 request_tracking_->GetReport(base::Bind(&GetReportCallback, 59 request_tracking_->GetReport(base::Bind(&GetReportCallback,
60 base::Unretained(message_loop()), 60 base::Unretained(message_loop()),
61 base::Unretained(report))); 61 base::Unretained(report)));
62 message_loop()->Run(); 62 message_loop()->Run();
63 } 63 }
64 64
65 private: 65 private:
66 template<typename T> 66 template <typename T>
67 void SetAndQuitImpl(T* val, T result) { 67 void SetAndQuitImpl(T* val, T result) {
68 *val = result; 68 *val = result;
69 message_loop()->QuitWhenIdle(); 69 message_loop()->QuitWhenIdle();
70 } 70 }
71 TestTrackedRequestServicePtr request_tracking_; 71 TestTrackedRequestServicePtr request_tracking_;
72 }; 72 };
73 73
74 class QuitMessageLoopErrorHandler : public ErrorHandler { 74 class QuitMessageLoopErrorHandler : public ErrorHandler {
75 public: 75 public:
76 QuitMessageLoopErrorHandler() {} 76 QuitMessageLoopErrorHandler() {}
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 EXPECT_EQ(TestTimeService::Name_, reports[1].service_name); 299 EXPECT_EQ(TestTimeService::Name_, reports[1].service_name);
300 EXPECT_EQ(1U, reports[1].total_requests); 300 EXPECT_EQ(1U, reports[1].total_requests);
301 EXPECT_EQ(TestTimeService::Name_, reports[2].service_name); 301 EXPECT_EQ(TestTimeService::Name_, reports[2].service_name);
302 EXPECT_EQ(20U, reports[2].total_requests); 302 EXPECT_EQ(20U, reports[2].total_requests);
303 } 303 }
304 304
305 } // namespace 305 } // namespace
306 } // namespace test 306 } // namespace test
307 } // namespace shell 307 } // namespace shell
308 } // namespace mojo 308 } // namespace mojo
OLDNEW
« no previous file with comments | « shell/shell_test_base.cc ('k') | shell/shell_test_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698