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

Side by Side Diff: examples/apptest/example_apptest.cc

Issue 1990603002: Make ApplicationTestBase not use ApplicationImpl. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: delete ApplicationImpl::WaitForInitialize() Created 4 years, 7 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 | « no previous file | mojo/file_utils/file_util_unittest.cc » ('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 <algorithm>
6
5 #include "examples/apptest/example_service.mojom.h" 7 #include "examples/apptest/example_service.mojom.h"
6 #include "mojo/public/cpp/application/application_impl.h"
7 #include "mojo/public/cpp/application/application_test_base.h" 8 #include "mojo/public/cpp/application/application_test_base.h"
8 #include "mojo/public/cpp/application/connect.h" 9 #include "mojo/public/cpp/application/connect.h"
9 #include "mojo/public/cpp/bindings/callback.h" 10 #include "mojo/public/cpp/bindings/callback.h"
10 #include "mojo/public/cpp/environment/logging.h" 11 #include "mojo/public/cpp/environment/logging.h"
11 #include "mojo/public/cpp/system/macros.h" 12 #include "mojo/public/cpp/system/macros.h"
12 13
13 namespace mojo { 14 namespace mojo {
14 namespace { 15 namespace {
15 16
16 // Exemplifies ApplicationTestBase's application testing pattern. 17 // Exemplifies ApplicationTestBase's application testing pattern.
17 class ExampleApplicationTest : public test::ApplicationTestBase { 18 class ExampleApplicationTest : public test::ApplicationTestBase {
18 public: 19 public:
19 ExampleApplicationTest() : ApplicationTestBase() {} 20 ExampleApplicationTest() : ApplicationTestBase() {}
20 ~ExampleApplicationTest() override {} 21 ~ExampleApplicationTest() override {}
21 22
22 protected: 23 protected:
23 // ApplicationTestBase: 24 // ApplicationTestBase:
24 void SetUp() override { 25 void SetUp() override {
25 ApplicationTestBase::SetUp(); 26 ApplicationTestBase::SetUp();
26 27
27 ConnectToService(application_impl()->shell(), "mojo:example_service", 28 ConnectToService(shell(), "mojo:example_service",
28 GetProxy(&example_service_)); 29 GetProxy(&example_service_));
29 } 30 }
30 31
31 ExampleServicePtr example_service_; 32 ExampleServicePtr example_service_;
32 33
33 private: 34 private:
34 MOJO_DISALLOW_COPY_AND_ASSIGN(ExampleApplicationTest); 35 MOJO_DISALLOW_COPY_AND_ASSIGN(ExampleApplicationTest);
35 }; 36 };
36 37
37 TEST_F(ExampleApplicationTest, PingServiceToPong) { 38 TEST_F(ExampleApplicationTest, PingServiceToPong) {
38 uint16_t pong_value = 0u; 39 uint16_t pong_value = 0u;
39 example_service_->Ping(1u, 40 example_service_->Ping(1u,
40 [&pong_value](uint16_t value) { pong_value = value; }); 41 [&pong_value](uint16_t value) { pong_value = value; });
41 EXPECT_TRUE(example_service_.WaitForIncomingResponse()); 42 EXPECT_TRUE(example_service_.WaitForIncomingResponse());
42 // Test making a call and receiving the reply. 43 // Test making a call and receiving the reply.
43 EXPECT_EQ(1u, pong_value); 44 EXPECT_EQ(1u, pong_value);
44 } 45 }
45 46
46 TEST_F(ExampleApplicationTest, CheckCommandLineArg) { 47 TEST_F(ExampleApplicationTest, CheckCommandLineArg) {
47 // Ensure the test runner passes along this example command line argument. 48 // Ensure the test runner passes along this example command line argument.
48 ASSERT_TRUE(application_impl()->HasArg("--example_apptest_arg")); 49 ASSERT_TRUE(std::find(args().begin(), args().end(),
50 "--example_apptest_arg") != args().end());
49 } 51 }
50 52
51 } // namespace 53 } // namespace
52 } // namespace mojo 54 } // namespace mojo
OLDNEW
« no previous file with comments | « no previous file | mojo/file_utils/file_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698