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