Index: components/mus/view_tree_apptest.cc |
diff --git a/components/mus/view_tree_apptest.cc b/components/mus/view_tree_apptest.cc |
index 7c598bb8a2dba086648319604f31b8ee7309c292..dfef44ec5589e3de604abe610619240898aa6d7a 100644 |
--- a/components/mus/view_tree_apptest.cc |
+++ b/components/mus/view_tree_apptest.cc |
@@ -18,11 +18,9 @@ using mojo::ApplicationConnection; |
using mojo::ApplicationDelegate; |
using mojo::Array; |
using mojo::Callback; |
-using mojo::ConnectionSpecificId; |
using mojo::ERROR_CODE_NONE; |
using mojo::ErrorCode; |
using mojo::EventPtr; |
-using mojo::Id; |
using mojo::InterfaceRequest; |
using mojo::ORDER_DIRECTION_ABOVE; |
using mojo::ORDER_DIRECTION_BELOW; |
@@ -36,7 +34,9 @@ using mojo::ViewTree; |
using mojo::ViewTreeClient; |
using mojo::ViewportMetricsPtr; |
-namespace view_manager { |
+namespace mus { |
+ |
+namespace { |
// Creates an id used for transport from the specified parameters. |
Id BuildViewId(ConnectionSpecificId connection_id, |
@@ -216,9 +216,8 @@ bool WaitForAllMessages(ViewTree* vm) { |
const Id kNullParentId = 0; |
std::string IdToString(Id id) { |
- return (id == kNullParentId) |
- ? "null" |
- : base::StringPrintf("%d,%d", mojo::HiWord(id), mojo::LoWord(id)); |
+ return (id == kNullParentId) ? "null" : base::StringPrintf( |
+ "%d,%d", HiWord(id), LoWord(id)); |
} |
std::string ViewParentToString(Id view, Id parent) { |
@@ -229,10 +228,10 @@ std::string ViewParentToString(Id view, Id parent) { |
// ----------------------------------------------------------------------------- |
// A ViewTreeClient implementation that logs all changes to a tracker. |
-class ViewTreeClientImpl : public mojo::ViewTreeClient, |
- public TestChangeTracker::Delegate { |
+class TestViewTreeClientImpl : public mojo::ViewTreeClient, |
+ public TestChangeTracker::Delegate { |
public: |
- explicit ViewTreeClientImpl(mojo::ApplicationImpl* app) |
+ explicit TestViewTreeClientImpl(mojo::ApplicationImpl* app) |
: binding_(this), app_(app), connection_id_(0), root_view_id_(0) { |
tracker_.set_delegate(this); |
} |
@@ -304,7 +303,7 @@ class ViewTreeClientImpl : public mojo::ViewTreeClient, |
void OnEmbed(ConnectionSpecificId connection_id, |
ViewDataPtr root, |
mojo::ViewTreePtr tree, |
- mojo::Id focused_view_id, |
+ Id focused_view_id, |
uint32_t access_policy) override { |
// TODO(sky): add coverage of |focused_view_id|. |
tree_ = tree.Pass(); |
@@ -382,19 +381,19 @@ class ViewTreeClientImpl : public mojo::ViewTreeClient, |
Id connection_id_; |
Id root_view_id_; |
- DISALLOW_COPY_AND_ASSIGN(ViewTreeClientImpl); |
+ DISALLOW_COPY_AND_ASSIGN(TestViewTreeClientImpl); |
}; |
// ----------------------------------------------------------------------------- |
-// InterfaceFactory for vending ViewTreeClientImpls. |
+// InterfaceFactory for vending TestViewTreeClientImpls. |
class ViewTreeClientFactory : public mojo::InterfaceFactory<ViewTreeClient> { |
public: |
explicit ViewTreeClientFactory(mojo::ApplicationImpl* app) : app_(app) {} |
~ViewTreeClientFactory() override {} |
// Runs a nested MessageLoop until a new instance has been created. |
- scoped_ptr<ViewTreeClientImpl> WaitForInstance() { |
+ scoped_ptr<TestViewTreeClientImpl> WaitForInstance() { |
if (!client_impl_.get()) { |
DCHECK(!run_loop_.get()); |
run_loop_.reset(new base::RunLoop); |
@@ -408,19 +407,21 @@ class ViewTreeClientFactory : public mojo::InterfaceFactory<ViewTreeClient> { |
// InterfaceFactory<ViewTreeClient>: |
void Create(ApplicationConnection* connection, |
InterfaceRequest<ViewTreeClient> request) override { |
- client_impl_.reset(new ViewTreeClientImpl(app_)); |
+ client_impl_.reset(new TestViewTreeClientImpl(app_)); |
client_impl_->Bind(request.Pass()); |
if (run_loop_.get()) |
run_loop_->Quit(); |
} |
mojo::ApplicationImpl* app_; |
- scoped_ptr<ViewTreeClientImpl> client_impl_; |
+ scoped_ptr<TestViewTreeClientImpl> client_impl_; |
scoped_ptr<base::RunLoop> run_loop_; |
DISALLOW_COPY_AND_ASSIGN(ViewTreeClientFactory); |
}; |
+} // namespace |
+ |
class ViewTreeAppTest : public mojo::test::ApplicationTestBase, |
public ApplicationDelegate { |
public: |
@@ -440,9 +441,9 @@ class ViewTreeAppTest : public mojo::test::ApplicationTestBase, |
ViewTree* vm2() { return vm_client2_->tree(); } |
ViewTree* vm3() { return vm_client3_->tree(); } |
- ViewTreeClientImpl* vm_client1() { return vm_client1_.get(); } |
- ViewTreeClientImpl* vm_client2() { return vm_client2_.get(); } |
- ViewTreeClientImpl* vm_client3() { return vm_client3_.get(); } |
+ TestViewTreeClientImpl* vm_client1() { return vm_client1_.get(); } |
+ TestViewTreeClientImpl* vm_client2() { return vm_client2_.get(); } |
+ TestViewTreeClientImpl* vm_client3() { return vm_client3_.get(); } |
Id root_view_id() const { return root_view_id_; } |
@@ -480,29 +481,30 @@ class ViewTreeAppTest : public mojo::test::ApplicationTestBase, |
vm_client3_->set_root_view(root_view_id_); |
} |
- scoped_ptr<ViewTreeClientImpl> WaitForViewTreeClient() { |
+ scoped_ptr<TestViewTreeClientImpl> WaitForViewTreeClient() { |
return client_factory_->WaitForInstance(); |
} |
// Establishes a new connection by way of Embed() on the specified |
// ViewTree. |
- scoped_ptr<ViewTreeClientImpl> |
+ scoped_ptr<TestViewTreeClientImpl> |
EstablishConnectionViaEmbed(ViewTree* owner, Id root_id, int* connection_id) { |
return EstablishConnectionViaEmbedWithPolicyBitmask( |
owner, root_id, mojo::ViewTree::ACCESS_POLICY_DEFAULT, connection_id); |
} |
- scoped_ptr<ViewTreeClientImpl> EstablishConnectionViaEmbedWithPolicyBitmask( |
- ViewTree* owner, |
- Id root_id, |
- uint32_t policy_bitmask, |
- int* connection_id) { |
+ scoped_ptr<TestViewTreeClientImpl> |
+ EstablishConnectionViaEmbedWithPolicyBitmask(ViewTree* owner, |
+ Id root_id, |
+ uint32_t policy_bitmask, |
+ int* connection_id) { |
if (!EmbedUrl(application_impl(), owner, application_impl()->url(), |
root_id)) { |
ADD_FAILURE() << "Embed() failed"; |
return nullptr; |
} |
- scoped_ptr<ViewTreeClientImpl> client = client_factory_->WaitForInstance(); |
+ scoped_ptr<TestViewTreeClientImpl> client = |
+ client_factory_->WaitForInstance(); |
if (!client.get()) { |
ADD_FAILURE() << "WaitForInstance failed"; |
return nullptr; |
@@ -528,7 +530,7 @@ class ViewTreeAppTest : public mojo::test::ApplicationTestBase, |
application_impl()->ConnectToService(request.Pass(), &factory); |
mojo::ViewTreeClientPtr tree_client_ptr; |
- vm_client1_.reset(new ViewTreeClientImpl(application_impl())); |
+ vm_client1_.reset(new TestViewTreeClientImpl(application_impl())); |
vm_client1_->Bind(GetProxy(&tree_client_ptr)); |
factory->CreateViewTreeHost(GetProxy(&host_), mojo::ViewTreeHostClientPtr(), |
@@ -556,9 +558,9 @@ class ViewTreeAppTest : public mojo::test::ApplicationTestBase, |
return true; |
} |
- scoped_ptr<ViewTreeClientImpl> vm_client1_; |
- scoped_ptr<ViewTreeClientImpl> vm_client2_; |
- scoped_ptr<ViewTreeClientImpl> vm_client3_; |
+ scoped_ptr<TestViewTreeClientImpl> vm_client1_; |
+ scoped_ptr<TestViewTreeClientImpl> vm_client2_; |
+ scoped_ptr<TestViewTreeClientImpl> vm_client3_; |
mojo::ViewTreeHostPtr host_; |
@@ -1265,7 +1267,7 @@ TEST_F(ViewTreeAppTest, EmbedWithSameViewId2) { |
changes3()->clear(); |
// We should get a new connection for the new embedding. |
- scoped_ptr<ViewTreeClientImpl> connection4( |
+ scoped_ptr<TestViewTreeClientImpl> connection4( |
EstablishConnectionViaEmbed(vm1(), view_1_1, nullptr)); |
ASSERT_TRUE(connection4.get()); |
EXPECT_EQ("[" + ViewParentToString(view_1_1, kNullParentId) + "]", |
@@ -1586,7 +1588,7 @@ TEST_F(ViewTreeAppTest, DontCleanMapOnDestroy) { |
TEST_F(ViewTreeAppTest, EmbedSupplyingViewTreeClient) { |
ASSERT_TRUE(vm_client1()->CreateView(1)); |
- ViewTreeClientImpl client2(application_impl()); |
+ TestViewTreeClientImpl client2(application_impl()); |
mojo::ViewTreeClientPtr client2_ptr; |
mojo::Binding<ViewTreeClient> client2_binding(&client2, &client2_ptr); |
ASSERT_TRUE( |
@@ -1674,4 +1676,4 @@ TEST_F(ViewTreeAppTest, CantEmbedFromConnectionRoot) { |
// ViewManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window manager |
// tests. |
-} // namespace view_manager |
+} // namespace mus |