| OLD | NEW |
| 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 <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/at_exit.h" | 8 #include "base/at_exit.h" |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "mojo/services/public/cpp/geometry/geometry_type_converters.h" | 24 #include "mojo/services/public/cpp/geometry/geometry_type_converters.h" |
| 25 #include "mojo/services/public/cpp/view_manager/types.h" | 25 #include "mojo/services/public/cpp/view_manager/types.h" |
| 26 #include "mojo/services/public/cpp/view_manager/util.h" | 26 #include "mojo/services/public/cpp/view_manager/util.h" |
| 27 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h" | 27 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h" |
| 28 #include "mojo/services/view_manager/ids.h" | 28 #include "mojo/services/view_manager/ids.h" |
| 29 #include "mojo/services/view_manager/test_change_tracker.h" | 29 #include "mojo/services/view_manager/test_change_tracker.h" |
| 30 #include "mojo/shell/shell_test_helper.h" | 30 #include "mojo/shell/shell_test_helper.h" |
| 31 #include "testing/gtest/include/gtest/gtest.h" | 31 #include "testing/gtest/include/gtest/gtest.h" |
| 32 #include "ui/gfx/geometry/rect.h" | 32 #include "ui/gfx/geometry/rect.h" |
| 33 | 33 |
| 34 #if defined(OS_WIN) |
| 35 #include "ui/gfx/win/window_impl.h" |
| 36 #endif |
| 37 |
| 34 namespace mojo { | 38 namespace mojo { |
| 35 namespace service { | 39 namespace service { |
| 36 | 40 |
| 37 namespace { | 41 namespace { |
| 38 | 42 |
| 39 const char kTestServiceURL[] = "mojo:test_url"; | 43 const char kTestServiceURL[] = "mojo:test_url"; |
| 40 const char kTestServiceURL2[] = "mojo:test_url2"; | 44 const char kTestServiceURL2[] = "mojo:test_url2"; |
| 41 | 45 |
| 42 // ViewManagerProxy is a proxy to an ViewManagerService. It handles invoking | 46 // ViewManagerProxy is a proxy to an ViewManagerService. It handles invoking |
| 43 // ViewManagerService functions on the right thread in a synchronous manner | 47 // ViewManagerService functions on the right thread in a synchronous manner |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 | 452 |
| 449 class ViewManagerTest : public testing::Test { | 453 class ViewManagerTest : public testing::Test { |
| 450 public: | 454 public: |
| 451 ViewManagerTest() | 455 ViewManagerTest() |
| 452 : connection_(NULL), | 456 : connection_(NULL), |
| 453 connection2_(NULL), | 457 connection2_(NULL), |
| 454 connection3_(NULL) {} | 458 connection3_(NULL) {} |
| 455 | 459 |
| 456 virtual void SetUp() OVERRIDE { | 460 virtual void SetUp() OVERRIDE { |
| 457 ASSERT_TRUE(ViewManagerProxy::IsInInitialState()); | 461 ASSERT_TRUE(ViewManagerProxy::IsInInitialState()); |
| 462 test_helper_.Init(); |
| 458 | 463 |
| 459 test_helper_.Init(); | 464 #if defined(OS_WIN) |
| 465 // As we unload the wndproc of window classes we need to be sure to |
| 466 // unregister them. |
| 467 gfx::WindowImpl::UnregisterClassesAtExit(); |
| 468 #endif |
| 460 | 469 |
| 461 test_helper_.SetLoaderForURL( | 470 test_helper_.SetLoaderForURL( |
| 462 scoped_ptr<ApplicationLoader>(new EmbedApplicationLoader()), | 471 scoped_ptr<ApplicationLoader>(new EmbedApplicationLoader()), |
| 463 GURL(kTestServiceURL)); | 472 GURL(kTestServiceURL)); |
| 464 | 473 |
| 465 test_helper_.SetLoaderForURL( | 474 test_helper_.SetLoaderForURL( |
| 466 scoped_ptr<ApplicationLoader>(new EmbedApplicationLoader()), | 475 scoped_ptr<ApplicationLoader>(new EmbedApplicationLoader()), |
| 467 GURL(kTestServiceURL2)); | 476 GURL(kTestServiceURL2)); |
| 468 | 477 |
| 469 test_helper_.application_manager()->ConnectToService( | 478 test_helper_.application_manager()->ConnectToService( |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 } | 558 } |
| 550 | 559 |
| 551 TEST_F(ViewManagerTest, MultipleEmbedRootsBeforeWTHReady) { | 560 TEST_F(ViewManagerTest, MultipleEmbedRootsBeforeWTHReady) { |
| 552 ASSERT_TRUE(InitEmbed(view_manager_init_.get(), kTestServiceURL, 2)); | 561 ASSERT_TRUE(InitEmbed(view_manager_init_.get(), kTestServiceURL, 2)); |
| 553 connection_->DoRunLoopUntilChangesCount(2); | 562 connection_->DoRunLoopUntilChangesCount(2); |
| 554 EXPECT_EQ(kTestServiceURL, connection_->changes()[0].embed_url); | 563 EXPECT_EQ(kTestServiceURL, connection_->changes()[0].embed_url); |
| 555 EXPECT_EQ(kTestServiceURL, connection_->changes()[1].embed_url); | 564 EXPECT_EQ(kTestServiceURL, connection_->changes()[1].embed_url); |
| 556 } | 565 } |
| 557 | 566 |
| 558 // Verifies client gets a valid id. | 567 // Verifies client gets a valid id. |
| 559 #if defined(OS_LINUX) | |
| 560 // http://crbug.com/396492 | 568 // http://crbug.com/396492 |
| 561 #define MAYBE_ValidId DISABLED_ValidId | 569 TEST_F(ViewManagerTest, DISABLED_ValidId) { |
| 562 #else | |
| 563 #define MAYBE_ValidId ValidId | |
| 564 #endif | |
| 565 TEST_F(ViewManagerTest, MAYBE_ValidId) { | |
| 566 // TODO(beng): this should really have the URL of the application that | 570 // TODO(beng): this should really have the URL of the application that |
| 567 // connected to ViewManagerInit. | 571 // connected to ViewManagerInit. |
| 568 EXPECT_EQ("OnEmbed creator=", | 572 EXPECT_EQ("OnEmbed creator=", |
| 569 ChangesToDescription1(connection_->changes())[0]); | 573 ChangesToDescription1(connection_->changes())[0]); |
| 570 | 574 |
| 571 // All these tests assume 1 for the client id. The only real assertion here is | 575 // All these tests assume 1 for the client id. The only real assertion here is |
| 572 // the client id is not zero, but adding this as rest of code here assumes 1. | 576 // the client id is not zero, but adding this as rest of code here assumes 1. |
| 573 EXPECT_EQ(1, connection_->changes()[0].connection_id); | 577 EXPECT_EQ(1, connection_->changes()[0].connection_id); |
| 574 } | 578 } |
| 575 | 579 |
| (...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1421 | 1425 |
| 1422 // TODO(sky): add coverage of test that destroys connections and ensures other | 1426 // TODO(sky): add coverage of test that destroys connections and ensures other |
| 1423 // connections get deletion notification. | 1427 // connections get deletion notification. |
| 1424 | 1428 |
| 1425 // TODO(sky): need to better track changes to initial connection. For example, | 1429 // TODO(sky): need to better track changes to initial connection. For example, |
| 1426 // that SetBounsdViews/AddView and the like don't result in messages to the | 1430 // that SetBounsdViews/AddView and the like don't result in messages to the |
| 1427 // originating connection. | 1431 // originating connection. |
| 1428 | 1432 |
| 1429 } // namespace service | 1433 } // namespace service |
| 1430 } // namespace mojo | 1434 } // namespace mojo |
| OLD | NEW |