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

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

Issue 744973002: Pass command line args to apptests (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebase and address comments 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 #include "examples/apptest/example_client_application.h" 5 #include "examples/apptest/example_client_application.h"
6 #include "examples/apptest/example_client_impl.h" 6 #include "examples/apptest/example_client_impl.h"
7 #include "examples/apptest/example_service.mojom.h" 7 #include "examples/apptest/example_service.mojom.h"
8 #include "mojo/public/cpp/application/application_impl.h" 8 #include "mojo/public/cpp/application/application_impl.h"
9 #include "mojo/public/cpp/application/application_test_base.h" 9 #include "mojo/public/cpp/application/application_test_base.h"
10 #include "mojo/public/cpp/bindings/callback.h" 10 #include "mojo/public/cpp/bindings/callback.h"
11 #include "mojo/public/cpp/environment/logging.h" 11 #include "mojo/public/cpp/environment/logging.h"
12 #include "mojo/public/cpp/system/macros.h" 12 #include "mojo/public/cpp/system/macros.h"
13 13
14 namespace mojo { 14 namespace mojo {
15 namespace { 15 namespace {
16 16
17 // Exemplifies ApplicationTestBase's application testing pattern. 17 // Exemplifies ApplicationTestBase's application testing pattern.
18 class ExampleApplicationTest : public test::ApplicationTestBase { 18 class ExampleApplicationTest : public test::ApplicationTestBase {
19 public: 19 public:
20 // TODO(msw): Exemplify the use of actual command line arguments. 20 ExampleApplicationTest() : ApplicationTestBase() {}
21 ExampleApplicationTest() : ApplicationTestBase(Array<String>()) {}
22 ~ExampleApplicationTest() override {} 21 ~ExampleApplicationTest() override {}
23 22
24 protected: 23 protected:
25 // ApplicationTestBase: 24 // ApplicationTestBase:
26 ApplicationDelegate* GetApplicationDelegate() override { 25 ApplicationDelegate* GetApplicationDelegate() override {
27 return &example_client_application_; 26 return &example_client_application_;
28 } 27 }
29 void SetUp() override { 28 void SetUp() override {
30 ApplicationTestBase::SetUp(); 29 ApplicationTestBase::SetUp();
30
31 application_impl()->ConnectToService("mojo:example_service", 31 application_impl()->ConnectToService("mojo:example_service",
32 &example_service_); 32 &example_service_);
33 example_service_.set_client(&example_client_); 33 example_service_.set_client(&example_client_);
34 } 34 }
35 35
36 ExampleServicePtr example_service_; 36 ExampleServicePtr example_service_;
37 ExampleClientImpl example_client_; 37 ExampleClientImpl example_client_;
38 38
39 private: 39 private:
40 ExampleClientApplication example_client_application_; 40 ExampleClientApplication example_client_application_;
(...skipping 27 matching lines...) Expand all
68 }; 68 };
69 69
70 TEST_F(ExampleApplicationTest, RunCallbackViaService) { 70 TEST_F(ExampleApplicationTest, RunCallbackViaService) {
71 // Test ExampleService callback functionality. 71 // Test ExampleService callback functionality.
72 bool was_run = false; 72 bool was_run = false;
73 example_service_->RunCallback(SetCallback<bool>(&was_run, true)); 73 example_service_->RunCallback(SetCallback<bool>(&was_run, true));
74 EXPECT_TRUE(example_service_.WaitForIncomingMethodCall()); 74 EXPECT_TRUE(example_service_.WaitForIncomingMethodCall());
75 EXPECT_TRUE(was_run); 75 EXPECT_TRUE(was_run);
76 } 76 }
77 77
78 TEST_F(ExampleApplicationTest, CheckCommandLineArg) {
79 // apptest_runner.py adds this argument unconditionally so we can check
80 // for it here to verify that command line args are getting passed to
81 // apptests.
82 ASSERT_TRUE(application_impl()->HasArg("--example_apptest_arg"));
83 }
84
78 } // namespace 85 } // namespace
79 } // namespace mojo 86 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698