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

Unified Diff: mojo/examples/apptest/example_apptest.cc

Issue 684543003: Move //mojo/examples to //examples (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/examples/apptest/BUILD.gn ('k') | mojo/examples/apptest/example_client_application.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/examples/apptest/example_apptest.cc
diff --git a/mojo/examples/apptest/example_apptest.cc b/mojo/examples/apptest/example_apptest.cc
deleted file mode 100644
index 4eb7ad5b978b76eb119bac316b3466cb54703af3..0000000000000000000000000000000000000000
--- a/mojo/examples/apptest/example_apptest.cc
+++ /dev/null
@@ -1,79 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "mojo/examples/apptest/example_client_application.h"
-#include "mojo/examples/apptest/example_client_impl.h"
-#include "mojo/examples/apptest/example_service.mojom.h"
-#include "mojo/public/cpp/application/application_impl.h"
-#include "mojo/public/cpp/application/application_test_base.h"
-#include "mojo/public/cpp/bindings/callback.h"
-#include "mojo/public/cpp/environment/logging.h"
-#include "mojo/public/cpp/system/macros.h"
-
-namespace mojo {
-namespace {
-
-// Exemplifies ApplicationTestBase's application testing pattern.
-class ExampleApplicationTest : public test::ApplicationTestBase {
- public:
- // TODO(msw): Exemplify the use of actual command line arguments.
- ExampleApplicationTest() : ApplicationTestBase(Array<String>()) {}
- ~ExampleApplicationTest() override {}
-
- protected:
- // ApplicationTestBase:
- ApplicationDelegate* GetApplicationDelegate() override {
- return &example_client_application_;
- }
- void SetUp() override {
- ApplicationTestBase::SetUp();
- application_impl()->ConnectToService("mojo:example_service",
- &example_service_);
- example_service_.set_client(&example_client_);
- }
-
- ExampleServicePtr example_service_;
- ExampleClientImpl example_client_;
-
- private:
- ExampleClientApplication example_client_application_;
-
- MOJO_DISALLOW_COPY_AND_ASSIGN(ExampleApplicationTest);
-};
-
-TEST_F(ExampleApplicationTest, PongClientDirectly) {
- // Test very basic standalone ExampleClient functionality.
- ExampleClientImpl example_client;
- EXPECT_EQ(0, example_client.last_pong_value());
- example_client.Pong(1);
- EXPECT_EQ(1, example_client.last_pong_value());
-}
-
-TEST_F(ExampleApplicationTest, PingServiceToPongClient) {
- // Test ExampleClient and ExampleService interaction.
- EXPECT_EQ(0, example_client_.last_pong_value());
- example_service_->Ping(1);
- EXPECT_TRUE(example_service_.WaitForIncomingMethodCall());
- EXPECT_EQ(1, example_client_.last_pong_value());
-}
-
-template <typename T>
-struct SetCallback : public Callback<void()>::Runnable {
- SetCallback(T* val, T result) : val_(val), result_(result) {}
- ~SetCallback() override {}
- void Run() const override { *val_ = result_; }
- T* val_;
- T result_;
-};
-
-TEST_F(ExampleApplicationTest, RunCallbackViaService) {
- // Test ExampleService callback functionality.
- bool was_run = false;
- example_service_->RunCallback(SetCallback<bool>(&was_run, true));
- EXPECT_TRUE(example_service_.WaitForIncomingMethodCall());
- EXPECT_TRUE(was_run);
-}
-
-} // namespace
-} // namespace mojo
« no previous file with comments | « mojo/examples/apptest/BUILD.gn ('k') | mojo/examples/apptest/example_client_application.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698