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

Unified Diff: components/mus/ws/view_tree_apptest.cc

Issue 1406153004: components/mus/public/interfaces View => Window (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Yet another rebase Created 5 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 | « components/mus/ws/view_manager_client_apptest.cc ('k') | components/mus/ws/view_tree_host_connection.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/mus/ws/view_tree_apptest.cc
diff --git a/components/mus/ws/view_tree_apptest.cc b/components/mus/ws/view_tree_apptest.cc
index 08c7be4502d38d6c2f56b109ca35fd06458b6c07..f035d278b637fe4ca5ac8c46be6b7675fe0598da 100644
--- a/components/mus/ws/view_tree_apptest.cc
+++ b/components/mus/ws/view_tree_apptest.cc
@@ -6,8 +6,8 @@
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
-#include "components/mus/public/interfaces/view_tree.mojom.h"
-#include "components/mus/public/interfaces/view_tree_host.mojom.h"
+#include "components/mus/public/interfaces/window_tree.mojom.h"
+#include "components/mus/public/interfaces/window_tree_host.mojom.h"
#include "components/mus/ws/ids.h"
#include "components/mus/ws/test_change_tracker.h"
#include "mojo/application/public/cpp/application_delegate.h"
@@ -18,21 +18,18 @@ using mojo::ApplicationConnection;
using mojo::ApplicationDelegate;
using mojo::Array;
using mojo::Callback;
-using mojo::ERROR_CODE_NONE;
-using mojo::ErrorCode;
using mojo::EventPtr;
using mojo::InterfaceRequest;
-using mojo::ORDER_DIRECTION_ABOVE;
-using mojo::ORDER_DIRECTION_BELOW;
-using mojo::OrderDirection;
using mojo::RectPtr;
using mojo::ServiceProvider;
using mojo::ServiceProviderPtr;
using mojo::String;
-using mojo::ViewDataPtr;
-using mojo::ViewTree;
-using mojo::ViewTreeClient;
-using mojo::ViewportMetricsPtr;
+using mus::mojom::ERROR_CODE_NONE;
+using mus::mojom::ErrorCode;
+using mus::mojom::ViewportMetricsPtr;
+using mus::mojom::WindowDataPtr;
+using mus::mojom::WindowTree;
+using mus::mojom::WindowTreeClient;
namespace mus {
@@ -40,11 +37,12 @@ namespace {
// Creates an id used for transport from the specified parameters.
Id BuildViewId(ConnectionSpecificId connection_id,
- ConnectionSpecificId view_id) {
- return (connection_id << 16) | view_id;
+ ConnectionSpecificId window_id) {
+ return (connection_id << 16) | window_id;
}
-// Callback function from ViewTree functions. ----------------------------------
+// Callback function from WindowTree functions.
+// ----------------------------------
void BoolResultCallback(base::RunLoop* run_loop,
bool* result_cache,
@@ -60,10 +58,10 @@ void ErrorCodeResultCallback(base::RunLoop* run_loop,
run_loop->Quit();
}
-void ViewTreeResultCallback(base::RunLoop* run_loop,
- std::vector<TestView>* views,
- Array<ViewDataPtr> results) {
- ViewDatasToTestViews(results, views);
+void WindowTreeResultCallback(base::RunLoop* run_loop,
+ std::vector<TestView>* views,
+ Array<WindowDataPtr> results) {
+ WindowDatasToTestViews(results, views);
run_loop->Quit();
}
@@ -78,7 +76,7 @@ void EmbedCallbackImpl(base::RunLoop* run_loop,
// -----------------------------------------------------------------------------
bool EmbedUrl(mojo::ApplicationImpl* app,
- ViewTree* vm,
+ WindowTree* vm,
const String& url,
Id root_id) {
bool result = false;
@@ -88,81 +86,82 @@ bool EmbedUrl(mojo::ApplicationImpl* app,
request->url = mojo::String::From(url);
scoped_ptr<ApplicationConnection> connection =
app->ConnectToApplication(request.Pass());
- mojo::ViewTreeClientPtr client;
+ mojom::WindowTreeClientPtr client;
connection->ConnectToService(&client);
- vm->Embed(root_id, client.Pass(), mojo::ViewTree::ACCESS_POLICY_DEFAULT,
+ vm->Embed(root_id, client.Pass(), mojom::WindowTree::ACCESS_POLICY_DEFAULT,
base::Bind(&EmbedCallbackImpl, &run_loop, &result));
}
run_loop.Run();
return result;
}
-bool Embed(ViewTree* vm, Id root_id, mojo::ViewTreeClientPtr client) {
+bool Embed(WindowTree* vm, Id root_id, mojom::WindowTreeClientPtr client) {
bool result = false;
base::RunLoop run_loop;
{
- vm->Embed(root_id, client.Pass(), mojo::ViewTree::ACCESS_POLICY_DEFAULT,
+ vm->Embed(root_id, client.Pass(), mojom::WindowTree::ACCESS_POLICY_DEFAULT,
base::Bind(&EmbedCallbackImpl, &run_loop, &result));
}
run_loop.Run();
return result;
}
-ErrorCode CreateViewWithErrorCode(ViewTree* vm, Id view_id) {
+ErrorCode NewWindowWithErrorCode(WindowTree* vm, Id window_id) {
ErrorCode result = ERROR_CODE_NONE;
base::RunLoop run_loop;
- vm->CreateView(view_id,
- base::Bind(&ErrorCodeResultCallback, &run_loop, &result));
+ vm->NewWindow(window_id,
+ base::Bind(&ErrorCodeResultCallback, &run_loop, &result));
run_loop.Run();
return result;
}
-bool AddView(ViewTree* vm, Id parent, Id child) {
+bool AddWindow(WindowTree* vm, Id parent, Id child) {
bool result = false;
base::RunLoop run_loop;
- vm->AddView(parent, child,
- base::Bind(&BoolResultCallback, &run_loop, &result));
+ vm->AddWindow(parent, child,
+ base::Bind(&BoolResultCallback, &run_loop, &result));
run_loop.Run();
return result;
}
-bool RemoveViewFromParent(ViewTree* vm, Id view_id) {
+bool RemoveWindowFromParent(WindowTree* vm, Id window_id) {
bool result = false;
base::RunLoop run_loop;
- vm->RemoveViewFromParent(view_id,
- base::Bind(&BoolResultCallback, &run_loop, &result));
+ vm->RemoveWindowFromParent(
+ window_id, base::Bind(&BoolResultCallback, &run_loop, &result));
run_loop.Run();
return result;
}
-bool ReorderView(ViewTree* vm,
- Id view_id,
- Id relative_view_id,
- OrderDirection direction) {
+bool ReorderWindow(WindowTree* vm,
+ Id window_id,
+ Id relative_window_id,
+ mojom::OrderDirection direction) {
bool result = false;
base::RunLoop run_loop;
- vm->ReorderView(view_id, relative_view_id, direction,
- base::Bind(&BoolResultCallback, &run_loop, &result));
+ vm->ReorderWindow(window_id, relative_window_id, direction,
+ base::Bind(&BoolResultCallback, &run_loop, &result));
run_loop.Run();
return result;
}
-void GetViewTree(ViewTree* vm, Id view_id, std::vector<TestView>* views) {
+void GetWindowTree(WindowTree* vm, Id window_id, std::vector<TestView>* views) {
base::RunLoop run_loop;
- vm->GetViewTree(view_id,
- base::Bind(&ViewTreeResultCallback, &run_loop, views));
+ vm->GetWindowTree(window_id,
+ base::Bind(&WindowTreeResultCallback, &run_loop, views));
run_loop.Run();
}
-bool DeleteView(ViewTree* vm, Id view_id) {
+bool DeleteWindow(WindowTree* vm, Id window_id) {
base::RunLoop run_loop;
bool result = false;
- vm->DeleteView(view_id, base::Bind(&BoolResultCallback, &run_loop, &result));
+ vm->DeleteWindow(window_id,
+ base::Bind(&BoolResultCallback, &run_loop, &result));
run_loop.Run();
return result;
}
-bool SetViewBounds(ViewTree* vm, Id view_id, int x, int y, int w, int h) {
+bool SetWindowBounds(WindowTree* vm, Id window_id, int x, int y, int w, int h) {
base::RunLoop run_loop;
bool result = false;
RectPtr rect(mojo::Rect::New());
@@ -170,32 +169,32 @@ bool SetViewBounds(ViewTree* vm, Id view_id, int x, int y, int w, int h) {
rect->y = y;
rect->width = w;
rect->height = h;
- vm->SetViewBounds(view_id, rect.Pass(),
- base::Bind(&BoolResultCallback, &run_loop, &result));
+ vm->SetWindowBounds(window_id, rect.Pass(),
+ base::Bind(&BoolResultCallback, &run_loop, &result));
run_loop.Run();
return result;
}
-bool SetViewVisibility(ViewTree* vm, Id view_id, bool visible) {
+bool SetWindowVisibility(WindowTree* vm, Id window_id, bool visible) {
base::RunLoop run_loop;
bool result = false;
- vm->SetViewVisibility(view_id, visible,
- base::Bind(&BoolResultCallback, &run_loop, &result));
+ vm->SetWindowVisibility(window_id, visible,
+ base::Bind(&BoolResultCallback, &run_loop, &result));
run_loop.Run();
return result;
}
-bool SetViewProperty(ViewTree* vm,
- Id view_id,
- const std::string& name,
- const std::vector<uint8_t>* data) {
+bool SetWindowProperty(WindowTree* vm,
+ Id window_id,
+ const std::string& name,
+ const std::vector<uint8_t>* data) {
base::RunLoop run_loop;
bool result = false;
Array<uint8_t> mojo_data;
if (data)
mojo_data = Array<uint8_t>::From(*data);
- vm->SetViewProperty(view_id, name, mojo_data.Pass(),
- base::Bind(&BoolResultCallback, &run_loop, &result));
+ vm->SetWindowProperty(window_id, name, mojo_data.Pass(),
+ base::Bind(&BoolResultCallback, &run_loop, &result));
run_loop.Run();
return result;
}
@@ -205,11 +204,11 @@ bool SetViewProperty(ViewTree* vm,
// Waits for all messages to be received by |vm|. This is done by attempting to
// create a bogus view. When we get the response we know all messages have been
// processed.
-bool WaitForAllMessages(ViewTree* vm) {
+bool WaitForAllMessages(WindowTree* vm) {
ErrorCode result = ERROR_CODE_NONE;
base::RunLoop run_loop;
- vm->CreateView(ViewIdToTransportId(InvalidViewId()),
- base::Bind(&ErrorCodeResultCallback, &run_loop, &result));
+ vm->NewWindow(ViewIdToTransportId(InvalidViewId()),
+ base::Bind(&ErrorCodeResultCallback, &run_loop, &result));
run_loop.Run();
return result != ERROR_CODE_NONE;
}
@@ -227,24 +226,24 @@ std::string ViewParentToString(Id view, Id parent) {
// -----------------------------------------------------------------------------
-// A ViewTreeClient implementation that logs all changes to a tracker.
-class TestViewTreeClientImpl : public mojo::ViewTreeClient,
- public TestChangeTracker::Delegate {
+// A WindowTreeClient implementation that logs all changes to a tracker.
+class TestWindowTreeClientImpl : public mojom::WindowTreeClient,
+ public TestChangeTracker::Delegate {
public:
- explicit TestViewTreeClientImpl(mojo::ApplicationImpl* app)
- : binding_(this), app_(app), connection_id_(0), root_view_id_(0) {
+ explicit TestWindowTreeClientImpl(mojo::ApplicationImpl* app)
+ : binding_(this), app_(app), connection_id_(0), root_window_id_(0) {
tracker_.set_delegate(this);
}
- void Bind(mojo::InterfaceRequest<mojo::ViewTreeClient> request) {
+ void Bind(mojo::InterfaceRequest<mojom::WindowTreeClient> request) {
binding_.Bind(request.Pass());
}
- mojo::ViewTree* tree() { return tree_.get(); }
+ mojom::WindowTree* tree() { return tree_.get(); }
TestChangeTracker* tracker() { return &tracker_; }
// Runs a nested MessageLoop until |count| changes (calls to
- // ViewTreeClient functions) have been received.
+ // WindowTreeClient functions) have been received.
void WaitForChangeCount(size_t count) {
if (tracker_.changes()->size() >= count)
return;
@@ -269,17 +268,17 @@ class TestViewTreeClientImpl : public mojo::ViewTreeClient,
return binding_.WaitForIncomingMethodCall();
}
- Id CreateView(ConnectionSpecificId view_id) {
+ Id NewWindow(ConnectionSpecificId window_id) {
ErrorCode result = ERROR_CODE_NONE;
base::RunLoop run_loop;
- Id id = BuildViewId(connection_id_, view_id);
- tree()->CreateView(
- id, base::Bind(&ErrorCodeResultCallback, &run_loop, &result));
+ Id id = BuildViewId(connection_id_, window_id);
+ tree()->NewWindow(id,
+ base::Bind(&ErrorCodeResultCallback, &run_loop, &result));
run_loop.Run();
return result == ERROR_CODE_NONE ? id : 0;
}
- void set_root_view(Id root_view_id) { root_view_id_ = root_view_id; }
+ void set_root_view(Id root_window_id) { root_window_id_ = root_window_id; }
private:
// Used when running a nested MessageLoop.
@@ -299,32 +298,32 @@ class TestViewTreeClientImpl : public mojo::ViewTreeClient,
}
}
- // ViewTreeClient:
+ // WindowTreeClient:
void OnEmbed(ConnectionSpecificId connection_id,
- ViewDataPtr root,
- mojo::ViewTreePtr tree,
- Id focused_view_id,
+ WindowDataPtr root,
+ mojom::WindowTreePtr tree,
+ Id focused_window_id,
uint32_t access_policy) override {
- // TODO(sky): add coverage of |focused_view_id|.
+ // TODO(sky): add coverage of |focused_window_id|.
tree_ = tree.Pass();
connection_id_ = connection_id;
tracker()->OnEmbed(connection_id, root.Pass());
if (embed_run_loop_)
embed_run_loop_->Quit();
}
- void OnEmbeddedAppDisconnected(Id view_id) override {
- tracker()->OnEmbeddedAppDisconnected(view_id);
+ void OnEmbeddedAppDisconnected(Id window_id) override {
+ tracker()->OnEmbeddedAppDisconnected(window_id);
}
void OnUnembed() override { tracker()->OnUnembed(); }
- void OnWindowBoundsChanged(Id view_id,
+ void OnWindowBoundsChanged(Id window_id,
RectPtr old_bounds,
RectPtr new_bounds) override {
// The bounds of the root may change during startup on Android at random
// times. As this doesn't matter, and shouldn't impact test exepctations,
// it is ignored.
- if (view_id == root_view_id_)
+ if (window_id == root_window_id_)
return;
- tracker()->OnWindowBoundsChanged(view_id, old_bounds.Pass(),
+ tracker()->OnWindowBoundsChanged(window_id, old_bounds.Pass(),
new_bounds.Pass());
}
void OnClientAreaChanged(uint32_t window_id,
@@ -338,14 +337,14 @@ class TestViewTreeClientImpl : public mojo::ViewTreeClient,
void OnWindowHierarchyChanged(Id view,
Id new_parent,
Id old_parent,
- Array<ViewDataPtr> views) override {
+ Array<WindowDataPtr> views) override {
tracker()->OnWindowHierarchyChanged(view, new_parent, old_parent,
views.Pass());
}
- void OnWindowReordered(Id view_id,
- Id relative_view_id,
- OrderDirection direction) override {
- tracker()->OnWindowReordered(view_id, relative_view_id, direction);
+ void OnWindowReordered(Id window_id,
+ Id relative_window_id,
+ mojom::OrderDirection direction) override {
+ tracker()->OnWindowReordered(window_id, relative_window_id, direction);
}
void OnWindowDeleted(Id view) override { tracker()->OnWindowDeleted(view); }
void OnWindowVisibilityChanged(uint32_t view, bool visible) override {
@@ -354,7 +353,7 @@ class TestViewTreeClientImpl : public mojo::ViewTreeClient,
void OnWindowDrawnStateChanged(uint32_t view, bool drawn) override {
tracker()->OnWindowDrawnStateChanged(view, drawn);
}
- void OnWindowInputEvent(Id view_id,
+ void OnWindowInputEvent(Id window_id,
EventPtr event,
const Callback<void()>& callback) override {
// Don't log input events as none of the tests care about them and they
@@ -367,11 +366,11 @@ class TestViewTreeClientImpl : public mojo::ViewTreeClient,
tracker_.OnWindowSharedPropertyChanged(view, name, new_data.Pass());
}
// TODO(sky): add testing coverage.
- void OnWindowFocused(uint32_t focused_view_id) override {}
+ void OnWindowFocused(uint32_t focused_window_id) override {}
TestChangeTracker tracker_;
- mojo::ViewTreePtr tree_;
+ mojom::WindowTreePtr tree_;
// If non-null we're waiting for OnEmbed() using this RunLoop.
scoped_ptr<base::RunLoop> embed_run_loop_;
@@ -380,24 +379,25 @@ class TestViewTreeClientImpl : public mojo::ViewTreeClient,
// be encountered.
scoped_ptr<WaitState> wait_state_;
- mojo::Binding<ViewTreeClient> binding_;
+ mojo::Binding<WindowTreeClient> binding_;
mojo::ApplicationImpl* app_;
Id connection_id_;
- Id root_view_id_;
+ Id root_window_id_;
- DISALLOW_COPY_AND_ASSIGN(TestViewTreeClientImpl);
+ DISALLOW_COPY_AND_ASSIGN(TestWindowTreeClientImpl);
};
// -----------------------------------------------------------------------------
-// InterfaceFactory for vending TestViewTreeClientImpls.
-class ViewTreeClientFactory : public mojo::InterfaceFactory<ViewTreeClient> {
+// InterfaceFactory for vending TestWindowTreeClientImpls.
+class WindowTreeClientFactory
+ : public mojo::InterfaceFactory<WindowTreeClient> {
public:
- explicit ViewTreeClientFactory(mojo::ApplicationImpl* app) : app_(app) {}
- ~ViewTreeClientFactory() override {}
+ explicit WindowTreeClientFactory(mojo::ApplicationImpl* app) : app_(app) {}
+ ~WindowTreeClientFactory() override {}
// Runs a nested MessageLoop until a new instance has been created.
- scoped_ptr<TestViewTreeClientImpl> WaitForInstance() {
+ scoped_ptr<TestWindowTreeClientImpl> WaitForInstance() {
if (!client_impl_.get()) {
DCHECK(!run_loop_.get());
run_loop_.reset(new base::RunLoop);
@@ -408,30 +408,30 @@ class ViewTreeClientFactory : public mojo::InterfaceFactory<ViewTreeClient> {
}
private:
- // InterfaceFactory<ViewTreeClient>:
+ // InterfaceFactory<WindowTreeClient>:
void Create(ApplicationConnection* connection,
- InterfaceRequest<ViewTreeClient> request) override {
- client_impl_.reset(new TestViewTreeClientImpl(app_));
+ InterfaceRequest<WindowTreeClient> request) override {
+ client_impl_.reset(new TestWindowTreeClientImpl(app_));
client_impl_->Bind(request.Pass());
if (run_loop_.get())
run_loop_->Quit();
}
mojo::ApplicationImpl* app_;
- scoped_ptr<TestViewTreeClientImpl> client_impl_;
+ scoped_ptr<TestWindowTreeClientImpl> client_impl_;
scoped_ptr<base::RunLoop> run_loop_;
- DISALLOW_COPY_AND_ASSIGN(ViewTreeClientFactory);
+ DISALLOW_COPY_AND_ASSIGN(WindowTreeClientFactory);
};
} // namespace
-class ViewTreeAppTest : public mojo::test::ApplicationTestBase,
- public ApplicationDelegate {
+class WindowTreeAppTest : public mojo::test::ApplicationTestBase,
+ public ApplicationDelegate {
public:
- ViewTreeAppTest()
- : connection_id_1_(0), connection_id_2_(0), root_view_id_(0) {}
- ~ViewTreeAppTest() override {}
+ WindowTreeAppTest()
+ : connection_id_1_(0), connection_id_2_(0), root_window_id_(0) {}
+ ~WindowTreeAppTest() override {}
protected:
// Returns the changes from the various connections.
@@ -441,15 +441,15 @@ class ViewTreeAppTest : public mojo::test::ApplicationTestBase,
// Various connections. |vm1()|, being the first connection, has special
// permissions (it's treated as the window manager).
- ViewTree* vm1() { return vm_client1_->tree(); }
- ViewTree* vm2() { return vm_client2_->tree(); }
- ViewTree* vm3() { return vm_client3_->tree(); }
+ WindowTree* vm1() { return vm_client1_->tree(); }
+ WindowTree* vm2() { return vm_client2_->tree(); }
+ WindowTree* vm3() { return vm_client3_->tree(); }
- TestViewTreeClientImpl* vm_client1() { return vm_client1_.get(); }
- TestViewTreeClientImpl* vm_client2() { return vm_client2_.get(); }
- TestViewTreeClientImpl* vm_client3() { return vm_client3_.get(); }
+ TestWindowTreeClientImpl* vm_client1() { return vm_client1_.get(); }
+ TestWindowTreeClientImpl* vm_client2() { return vm_client2_.get(); }
+ TestWindowTreeClientImpl* vm_client3() { return vm_client3_.get(); }
- Id root_view_id() const { return root_view_id_; }
+ Id root_window_id() const { return root_window_id_; }
int connection_id_1() const { return connection_id_1_; }
int connection_id_2() const { return connection_id_2_; }
@@ -460,13 +460,13 @@ class ViewTreeAppTest : public mojo::test::ApplicationTestBase,
EstablishConnectionViaEmbed(vm1(), root_id, &connection_id_2_);
ASSERT_GT(connection_id_2_, 0);
ASSERT_TRUE(vm_client2_.get() != nullptr);
- vm_client2_->set_root_view(root_view_id_);
+ vm_client2_->set_root_view(root_window_id_);
}
void EstablishSecondConnection(bool create_initial_view) {
Id view_1_1 = 0;
if (create_initial_view) {
- view_1_1 = vm_client1()->CreateView(1);
+ view_1_1 = vm_client1()->NewWindow(1);
ASSERT_TRUE(view_1_1);
}
ASSERT_NO_FATAL_FAILURE(
@@ -478,27 +478,30 @@ class ViewTreeAppTest : public mojo::test::ApplicationTestBase,
}
}
- void EstablishThirdConnection(ViewTree* owner, Id root_id) {
+ void EstablishThirdConnection(WindowTree* owner, Id root_id) {
ASSERT_TRUE(vm_client3_.get() == nullptr);
vm_client3_ = EstablishConnectionViaEmbed(owner, root_id, nullptr);
ASSERT_TRUE(vm_client3_.get() != nullptr);
- vm_client3_->set_root_view(root_view_id_);
+ vm_client3_->set_root_view(root_window_id_);
}
- scoped_ptr<TestViewTreeClientImpl> WaitForViewTreeClient() {
+ scoped_ptr<TestWindowTreeClientImpl> WaitForWindowTreeClient() {
return client_factory_->WaitForInstance();
}
// Establishes a new connection by way of Embed() on the specified
- // ViewTree.
- scoped_ptr<TestViewTreeClientImpl>
- EstablishConnectionViaEmbed(ViewTree* owner, Id root_id, int* connection_id) {
+ // WindowTree.
+ scoped_ptr<TestWindowTreeClientImpl> EstablishConnectionViaEmbed(
+ WindowTree* owner,
+ Id root_id,
+ int* connection_id) {
return EstablishConnectionViaEmbedWithPolicyBitmask(
- owner, root_id, mojo::ViewTree::ACCESS_POLICY_DEFAULT, connection_id);
+ owner, root_id, mojom::WindowTree::ACCESS_POLICY_DEFAULT,
+ connection_id);
}
- scoped_ptr<TestViewTreeClientImpl>
- EstablishConnectionViaEmbedWithPolicyBitmask(ViewTree* owner,
+ scoped_ptr<TestWindowTreeClientImpl>
+ EstablishConnectionViaEmbedWithPolicyBitmask(WindowTree* owner,
Id root_id,
uint32_t policy_bitmask,
int* connection_id) {
@@ -507,7 +510,7 @@ class ViewTreeAppTest : public mojo::test::ApplicationTestBase,
ADD_FAILURE() << "Embed() failed";
return nullptr;
}
- scoped_ptr<TestViewTreeClientImpl> client =
+ scoped_ptr<TestWindowTreeClientImpl> client =
client_factory_->WaitForInstance();
if (!client.get()) {
ADD_FAILURE() << "WaitForInstance failed";
@@ -526,19 +529,19 @@ class ViewTreeAppTest : public mojo::test::ApplicationTestBase,
ApplicationDelegate* GetApplicationDelegate() override { return this; }
void SetUp() override {
ApplicationTestBase::SetUp();
- client_factory_.reset(new ViewTreeClientFactory(application_impl()));
+ client_factory_.reset(new WindowTreeClientFactory(application_impl()));
mojo::URLRequestPtr request(mojo::URLRequest::New());
request->url = mojo::String::From("mojo:mus");
- mojo::ViewTreeHostFactoryPtr factory;
+ mojom::WindowTreeHostFactoryPtr factory;
application_impl()->ConnectToService(request.Pass(), &factory);
- mojo::ViewTreeClientPtr tree_client_ptr;
- vm_client1_.reset(new TestViewTreeClientImpl(application_impl()));
+ mojom::WindowTreeClientPtr tree_client_ptr;
+ vm_client1_.reset(new TestWindowTreeClientImpl(application_impl()));
vm_client1_->Bind(GetProxy(&tree_client_ptr));
factory->CreateWindowTreeHost(GetProxy(&host_),
- mojo::ViewTreeHostClientPtr(),
+ mojom::WindowTreeHostClientPtr(),
tree_client_ptr.Pass());
// Next we should get an embed call on the "window manager" client.
@@ -552,8 +555,8 @@ class ViewTreeAppTest : public mojo::test::ApplicationTestBase,
ASSERT_GT((*changes1())[0].connection_id, 0);
connection_id_1_ = (*changes1())[0].connection_id;
ASSERT_FALSE((*changes1())[0].views.empty());
- root_view_id_ = (*changes1())[0].views[0].view_id;
- vm_client1_->set_root_view(root_view_id_);
+ root_window_id_ = (*changes1())[0].views[0].window_id;
+ vm_client1_->set_root_view(root_window_id_);
changes1()->clear();
}
@@ -563,23 +566,23 @@ class ViewTreeAppTest : public mojo::test::ApplicationTestBase,
return true;
}
- scoped_ptr<TestViewTreeClientImpl> vm_client1_;
- scoped_ptr<TestViewTreeClientImpl> vm_client2_;
- scoped_ptr<TestViewTreeClientImpl> vm_client3_;
+ scoped_ptr<TestWindowTreeClientImpl> vm_client1_;
+ scoped_ptr<TestWindowTreeClientImpl> vm_client2_;
+ scoped_ptr<TestWindowTreeClientImpl> vm_client3_;
- mojo::ViewTreeHostPtr host_;
+ mojom::WindowTreeHostPtr host_;
private:
- scoped_ptr<ViewTreeClientFactory> client_factory_;
+ scoped_ptr<WindowTreeClientFactory> client_factory_;
int connection_id_1_;
int connection_id_2_;
- Id root_view_id_;
+ Id root_window_id_;
- MOJO_DISALLOW_COPY_AND_ASSIGN(ViewTreeAppTest);
+ MOJO_DISALLOW_COPY_AND_ASSIGN(WindowTreeAppTest);
};
// Verifies two clients/connections get different ids.
-TEST_F(ViewTreeAppTest, TwoClientsGetDifferentConnectionIds) {
+TEST_F(WindowTreeAppTest, TwoClientsGetDifferentConnectionIds) {
ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
ASSERT_EQ(1u, changes2()->size());
@@ -587,15 +590,15 @@ TEST_F(ViewTreeAppTest, TwoClientsGetDifferentConnectionIds) {
}
// Verifies when Embed() is invoked any child views are removed.
-TEST_F(ViewTreeAppTest, ViewsRemovedWhenEmbedding) {
+TEST_F(WindowTreeAppTest, ViewsRemovedWhenEmbedding) {
// Two views 1 and 2. 2 is parented to 1.
- Id view_1_1 = vm_client1()->CreateView(1);
+ Id view_1_1 = vm_client1()->NewWindow(1);
ASSERT_TRUE(view_1_1);
- ASSERT_TRUE(AddView(vm1(), root_view_id(), view_1_1));
+ ASSERT_TRUE(AddWindow(vm1(), root_window_id(), view_1_1));
- Id view_1_2 = vm_client1()->CreateView(2);
+ Id view_1_2 = vm_client1()->NewWindow(2);
ASSERT_TRUE(view_1_2);
- ASSERT_TRUE(AddView(vm1(), view_1_1, view_1_2));
+ ASSERT_TRUE(AddWindow(vm1(), view_1_1, view_1_2));
ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false));
ASSERT_EQ(1u, changes2()->size());
@@ -606,7 +609,7 @@ TEST_F(ViewTreeAppTest, ViewsRemovedWhenEmbedding) {
// Embed() removed view 2.
{
std::vector<TestView> views;
- GetViewTree(vm1(), view_1_2, &views);
+ GetWindowTree(vm1(), view_1_2, &views);
EXPECT_EQ(ViewParentToString(view_1_2, kNullParentId),
SingleViewDescription(views));
}
@@ -614,22 +617,22 @@ TEST_F(ViewTreeAppTest, ViewsRemovedWhenEmbedding) {
// vm2 should not see view 2.
{
std::vector<TestView> views;
- GetViewTree(vm2(), view_1_1, &views);
+ GetWindowTree(vm2(), view_1_1, &views);
EXPECT_EQ(ViewParentToString(view_1_1, kNullParentId),
SingleViewDescription(views));
}
{
std::vector<TestView> views;
- GetViewTree(vm2(), view_1_2, &views);
+ GetWindowTree(vm2(), view_1_2, &views);
EXPECT_TRUE(views.empty());
}
// Views 3 and 4 in connection 2.
- Id view_2_3 = vm_client2()->CreateView(3);
- Id view_2_4 = vm_client2()->CreateView(4);
+ Id view_2_3 = vm_client2()->NewWindow(3);
+ Id view_2_4 = vm_client2()->NewWindow(4);
ASSERT_TRUE(view_2_3);
ASSERT_TRUE(view_2_4);
- ASSERT_TRUE(AddView(vm2(), view_2_3, view_2_4));
+ ASSERT_TRUE(AddWindow(vm2(), view_2_3, view_2_4));
// Connection 3 rooted at 2.
ASSERT_NO_FATAL_FAILURE(EstablishThirdConnection(vm2(), view_2_3));
@@ -637,12 +640,12 @@ TEST_F(ViewTreeAppTest, ViewsRemovedWhenEmbedding) {
// View 4 should no longer have a parent.
{
std::vector<TestView> views;
- GetViewTree(vm2(), view_2_3, &views);
+ GetWindowTree(vm2(), view_2_3, &views);
EXPECT_EQ(ViewParentToString(view_2_3, kNullParentId),
SingleViewDescription(views));
views.clear();
- GetViewTree(vm2(), view_2_4, &views);
+ GetWindowTree(vm2(), view_2_4, &views);
EXPECT_EQ(ViewParentToString(view_2_4, kNullParentId),
SingleViewDescription(views));
}
@@ -650,7 +653,7 @@ TEST_F(ViewTreeAppTest, ViewsRemovedWhenEmbedding) {
// And view 4 should not be visible to connection 3.
{
std::vector<TestView> views;
- GetViewTree(vm3(), view_2_3, &views);
+ GetWindowTree(vm3(), view_2_3, &views);
EXPECT_EQ(ViewParentToString(view_2_3, kNullParentId),
SingleViewDescription(views));
}
@@ -658,25 +661,25 @@ TEST_F(ViewTreeAppTest, ViewsRemovedWhenEmbedding) {
// Verifies once Embed() has been invoked the parent connection can't see any
// children.
-TEST_F(ViewTreeAppTest, CantAccessChildrenOfEmbeddedView) {
+TEST_F(WindowTreeAppTest, CantAccessChildrenOfEmbeddedView) {
ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
Id view_1_1 = BuildViewId(connection_id_1(), 1);
- Id view_2_2 = vm_client2()->CreateView(2);
+ Id view_2_2 = vm_client2()->NewWindow(2);
ASSERT_TRUE(view_2_2);
- ASSERT_TRUE(AddView(vm2(), view_1_1, view_2_2));
+ ASSERT_TRUE(AddWindow(vm2(), view_1_1, view_2_2));
ASSERT_NO_FATAL_FAILURE(EstablishThirdConnection(vm2(), view_2_2));
- Id view_3_3 = vm_client3()->CreateView(3);
+ Id view_3_3 = vm_client3()->NewWindow(3);
ASSERT_TRUE(view_3_3);
- ASSERT_TRUE(AddView(vm3(), view_2_2, view_3_3));
+ ASSERT_TRUE(AddWindow(vm3(), view_2_2, view_3_3));
// Even though 3 is a child of 2 connection 2 can't see 3 as it's from a
// different connection.
{
std::vector<TestView> views;
- GetViewTree(vm2(), view_2_2, &views);
+ GetWindowTree(vm2(), view_2_2, &views);
EXPECT_EQ(ViewParentToString(view_2_2, view_1_1),
SingleViewDescription(views));
}
@@ -684,14 +687,14 @@ TEST_F(ViewTreeAppTest, CantAccessChildrenOfEmbeddedView) {
// Connection 2 shouldn't be able to get view 3 at all.
{
std::vector<TestView> views;
- GetViewTree(vm2(), view_3_3, &views);
+ GetWindowTree(vm2(), view_3_3, &views);
EXPECT_TRUE(views.empty());
}
// Connection 1 should be able to see it all (its the root).
{
std::vector<TestView> views;
- GetViewTree(vm1(), view_1_1, &views);
+ GetWindowTree(vm1(), view_1_1, &views);
ASSERT_EQ(3u, views.size());
EXPECT_EQ(ViewParentToString(view_1_1, kNullParentId), views[0].ToString());
EXPECT_EQ(ViewParentToString(view_2_2, view_1_1), views[1].ToString());
@@ -700,84 +703,84 @@ TEST_F(ViewTreeAppTest, CantAccessChildrenOfEmbeddedView) {
}
// Verifies once Embed() has been invoked the parent can't mutate the children.
-TEST_F(ViewTreeAppTest, CantModifyChildrenOfEmbeddedView) {
+TEST_F(WindowTreeAppTest, CantModifyChildrenOfEmbeddedView) {
ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
Id view_1_1 = BuildViewId(connection_id_1(), 1);
- Id view_2_2 = vm_client2()->CreateView(2);
+ Id view_2_2 = vm_client2()->NewWindow(2);
ASSERT_TRUE(view_2_2);
- ASSERT_TRUE(AddView(vm2(), view_1_1, view_2_2));
+ ASSERT_TRUE(AddWindow(vm2(), view_1_1, view_2_2));
ASSERT_NO_FATAL_FAILURE(EstablishThirdConnection(vm2(), view_2_2));
- Id view_2_3 = vm_client2()->CreateView(3);
+ Id view_2_3 = vm_client2()->NewWindow(3);
ASSERT_TRUE(view_2_3);
// Connection 2 shouldn't be able to add anything to the view anymore.
- ASSERT_FALSE(AddView(vm2(), view_2_2, view_2_3));
+ ASSERT_FALSE(AddWindow(vm2(), view_2_2, view_2_3));
// Create view 3 in connection 3 and add it to view 3.
- Id view_3_3 = vm_client3()->CreateView(3);
+ Id view_3_3 = vm_client3()->NewWindow(3);
ASSERT_TRUE(view_3_3);
- ASSERT_TRUE(AddView(vm3(), view_2_2, view_3_3));
+ ASSERT_TRUE(AddWindow(vm3(), view_2_2, view_3_3));
// Connection 2 shouldn't be able to remove view 3.
- ASSERT_FALSE(RemoveViewFromParent(vm2(), view_3_3));
+ ASSERT_FALSE(RemoveWindowFromParent(vm2(), view_3_3));
}
// Verifies client gets a valid id.
-TEST_F(ViewTreeAppTest, CreateView) {
- Id view_1_1 = vm_client1()->CreateView(1);
+TEST_F(WindowTreeAppTest, NewWindow) {
+ Id view_1_1 = vm_client1()->NewWindow(1);
ASSERT_TRUE(view_1_1);
EXPECT_TRUE(changes1()->empty());
// Can't create a view with the same id.
- ASSERT_EQ(mojo::ERROR_CODE_VALUE_IN_USE,
- CreateViewWithErrorCode(vm1(), view_1_1));
+ ASSERT_EQ(mojom::ERROR_CODE_VALUE_IN_USE,
+ NewWindowWithErrorCode(vm1(), view_1_1));
EXPECT_TRUE(changes1()->empty());
// Can't create a view with a bogus connection id.
EXPECT_EQ(
- mojo::ERROR_CODE_ILLEGAL_ARGUMENT,
- CreateViewWithErrorCode(vm1(), BuildViewId(connection_id_1() + 1, 1)));
+ mojom::ERROR_CODE_ILLEGAL_ARGUMENT,
+ NewWindowWithErrorCode(vm1(), BuildViewId(connection_id_1() + 1, 1)));
EXPECT_TRUE(changes1()->empty());
}
-// Verifies AddView fails when view is already in position.
-TEST_F(ViewTreeAppTest, AddViewWithNoChange) {
- Id view_1_2 = vm_client1()->CreateView(2);
- Id view_1_3 = vm_client1()->CreateView(3);
+// Verifies AddWindow fails when view is already in position.
+TEST_F(WindowTreeAppTest, AddWindowWithNoChange) {
+ Id view_1_2 = vm_client1()->NewWindow(2);
+ Id view_1_3 = vm_client1()->NewWindow(3);
ASSERT_TRUE(view_1_2);
ASSERT_TRUE(view_1_3);
ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
// Make 3 a child of 2.
- ASSERT_TRUE(AddView(vm1(), view_1_2, view_1_3));
+ ASSERT_TRUE(AddWindow(vm1(), view_1_2, view_1_3));
// Try again, this should fail.
- EXPECT_FALSE(AddView(vm1(), view_1_2, view_1_3));
+ EXPECT_FALSE(AddWindow(vm1(), view_1_2, view_1_3));
}
-// Verifies AddView fails when view is already in position.
-TEST_F(ViewTreeAppTest, AddAncestorFails) {
- Id view_1_2 = vm_client1()->CreateView(2);
- Id view_1_3 = vm_client1()->CreateView(3);
+// Verifies AddWindow fails when view is already in position.
+TEST_F(WindowTreeAppTest, AddAncestorFails) {
+ Id view_1_2 = vm_client1()->NewWindow(2);
+ Id view_1_3 = vm_client1()->NewWindow(3);
ASSERT_TRUE(view_1_2);
ASSERT_TRUE(view_1_3);
ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
// Make 3 a child of 2.
- ASSERT_TRUE(AddView(vm1(), view_1_2, view_1_3));
+ ASSERT_TRUE(AddWindow(vm1(), view_1_2, view_1_3));
// Try to make 2 a child of 3, this should fail since 2 is an ancestor of 3.
- EXPECT_FALSE(AddView(vm1(), view_1_3, view_1_2));
+ EXPECT_FALSE(AddWindow(vm1(), view_1_3, view_1_2));
}
// Verifies adding to root sends right notifications.
-TEST_F(ViewTreeAppTest, AddToRoot) {
- Id view_1_21 = vm_client1()->CreateView(21);
- Id view_1_3 = vm_client1()->CreateView(3);
+TEST_F(WindowTreeAppTest, AddToRoot) {
+ Id view_1_21 = vm_client1()->NewWindow(21);
+ Id view_1_3 = vm_client1()->NewWindow(3);
ASSERT_TRUE(view_1_21);
ASSERT_TRUE(view_1_3);
@@ -786,32 +789,32 @@ TEST_F(ViewTreeAppTest, AddToRoot) {
changes2()->clear();
// Make 3 a child of 21.
- ASSERT_TRUE(AddView(vm1(), view_1_21, view_1_3));
+ ASSERT_TRUE(AddWindow(vm1(), view_1_21, view_1_3));
// Make 21 a child of 1.
- ASSERT_TRUE(AddView(vm1(), view_1_1, view_1_21));
+ ASSERT_TRUE(AddWindow(vm1(), view_1_1, view_1_21));
// Connection 2 should not be told anything (because the view is from a
// different connection). Create a view to ensure we got a response from
// the server.
- ASSERT_TRUE(vm_client2()->CreateView(100));
+ ASSERT_TRUE(vm_client2()->NewWindow(100));
EXPECT_TRUE(changes2()->empty());
}
// Verifies HierarchyChanged is correctly sent for various adds/removes.
-TEST_F(ViewTreeAppTest, ViewHierarchyChangedViews) {
+TEST_F(WindowTreeAppTest, ViewHierarchyChangedViews) {
// 1,2->1,11.
- Id view_1_2 = vm_client1()->CreateView(2);
+ Id view_1_2 = vm_client1()->NewWindow(2);
ASSERT_TRUE(view_1_2);
- ASSERT_TRUE(SetViewVisibility(vm1(), view_1_2, true));
- Id view_1_11 = vm_client1()->CreateView(11);
+ ASSERT_TRUE(SetWindowVisibility(vm1(), view_1_2, true));
+ Id view_1_11 = vm_client1()->NewWindow(11);
ASSERT_TRUE(view_1_11);
- ASSERT_TRUE(SetViewVisibility(vm1(), view_1_11, true));
- ASSERT_TRUE(AddView(vm1(), view_1_2, view_1_11));
+ ASSERT_TRUE(SetWindowVisibility(vm1(), view_1_11, true));
+ ASSERT_TRUE(AddWindow(vm1(), view_1_2, view_1_11));
Id view_1_1 = BuildViewId(connection_id_1(), 1);
ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
- ASSERT_TRUE(SetViewVisibility(vm1(), view_1_1, true));
+ ASSERT_TRUE(SetWindowVisibility(vm1(), view_1_1, true));
ASSERT_TRUE(WaitForAllMessages(vm2()));
changes2()->clear();
@@ -819,7 +822,7 @@ TEST_F(ViewTreeAppTest, ViewHierarchyChangedViews) {
// 1,1->1,2->1,11
{
// Client 2 should not get anything (1,2 is from another connection).
- ASSERT_TRUE(AddView(vm1(), view_1_1, view_1_2));
+ ASSERT_TRUE(AddWindow(vm1(), view_1_1, view_1_2));
ASSERT_TRUE(WaitForAllMessages(vm2()));
EXPECT_TRUE(changes2()->empty());
}
@@ -828,7 +831,7 @@ TEST_F(ViewTreeAppTest, ViewHierarchyChangedViews) {
{
// Client 2 is now connected to the root, so it should have gotten a drawn
// notification.
- ASSERT_TRUE(AddView(vm1(), root_view_id(), view_1_1));
+ ASSERT_TRUE(AddWindow(vm1(), root_window_id(), view_1_1));
vm_client2_->WaitForChangeCount(1u);
EXPECT_EQ("DrawnStateChanged view=" + IdToString(view_1_1) + " drawn=true",
SingleChangeToDescription(*changes2()));
@@ -839,19 +842,19 @@ TEST_F(ViewTreeAppTest, ViewHierarchyChangedViews) {
// Client 2 is no longer connected to the root, should get drawn state
// changed.
changes2()->clear();
- ASSERT_TRUE(RemoveViewFromParent(vm1(), view_1_1));
+ ASSERT_TRUE(RemoveWindowFromParent(vm1(), view_1_1));
vm_client2_->WaitForChangeCount(1);
EXPECT_EQ("DrawnStateChanged view=" + IdToString(view_1_1) + " drawn=false",
SingleChangeToDescription(*changes2()));
}
// 1,1->1,2->1,11->1,111.
- Id view_1_111 = vm_client1()->CreateView(111);
+ Id view_1_111 = vm_client1()->NewWindow(111);
ASSERT_TRUE(view_1_111);
- ASSERT_TRUE(SetViewVisibility(vm1(), view_1_111, true));
+ ASSERT_TRUE(SetWindowVisibility(vm1(), view_1_111, true));
{
changes2()->clear();
- ASSERT_TRUE(AddView(vm1(), view_1_11, view_1_111));
+ ASSERT_TRUE(AddWindow(vm1(), view_1_11, view_1_111));
ASSERT_TRUE(WaitForAllMessages(vm2()));
EXPECT_TRUE(changes2()->empty());
}
@@ -859,35 +862,35 @@ TEST_F(ViewTreeAppTest, ViewHierarchyChangedViews) {
// 0,1->1,1->1,2->1,11->1,111
{
changes2()->clear();
- ASSERT_TRUE(AddView(vm1(), root_view_id(), view_1_1));
+ ASSERT_TRUE(AddWindow(vm1(), root_window_id(), view_1_1));
vm_client2_->WaitForChangeCount(1);
EXPECT_EQ("DrawnStateChanged view=" + IdToString(view_1_1) + " drawn=true",
SingleChangeToDescription(*changes2()));
}
}
-TEST_F(ViewTreeAppTest, ViewHierarchyChangedAddingKnownToUnknown) {
+TEST_F(WindowTreeAppTest, ViewHierarchyChangedAddingKnownToUnknown) {
// Create the following structure: root -> 1 -> 11 and 2->21 (2 has no
// parent).
ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
Id view_1_1 = BuildViewId(connection_id_1(), 1);
- Id view_2_11 = vm_client2()->CreateView(11);
- Id view_2_2 = vm_client2()->CreateView(2);
- Id view_2_21 = vm_client2()->CreateView(21);
+ Id view_2_11 = vm_client2()->NewWindow(11);
+ Id view_2_2 = vm_client2()->NewWindow(2);
+ Id view_2_21 = vm_client2()->NewWindow(21);
ASSERT_TRUE(view_2_11);
ASSERT_TRUE(view_2_2);
ASSERT_TRUE(view_2_21);
// Set up the hierarchy.
- ASSERT_TRUE(AddView(vm1(), root_view_id(), view_1_1));
- ASSERT_TRUE(AddView(vm2(), view_1_1, view_2_11));
- ASSERT_TRUE(AddView(vm2(), view_2_2, view_2_21));
+ ASSERT_TRUE(AddWindow(vm1(), root_window_id(), view_1_1));
+ ASSERT_TRUE(AddWindow(vm2(), view_1_1, view_2_11));
+ ASSERT_TRUE(AddWindow(vm2(), view_2_2, view_2_21));
// Remove 11, should result in a hierarchy change for the root.
{
changes1()->clear();
- ASSERT_TRUE(RemoveViewFromParent(vm2(), view_2_11));
+ ASSERT_TRUE(RemoveWindowFromParent(vm2(), view_2_11));
vm_client1_->WaitForChangeCount(1);
EXPECT_EQ("HierarchyChanged view=" + IdToString(view_2_11) +
@@ -898,7 +901,7 @@ TEST_F(ViewTreeAppTest, ViewHierarchyChangedAddingKnownToUnknown) {
// Add 2 to 1.
{
changes1()->clear();
- ASSERT_TRUE(AddView(vm2(), view_1_1, view_2_2));
+ ASSERT_TRUE(AddWindow(vm2(), view_1_1, view_2_2));
vm_client1_->WaitForChangeCount(1);
EXPECT_EQ("HierarchyChanged view=" + IdToString(view_2_2) + " new_parent=" +
IdToString(view_1_1) + " old_parent=null",
@@ -909,17 +912,17 @@ TEST_F(ViewTreeAppTest, ViewHierarchyChangedAddingKnownToUnknown) {
}
}
-TEST_F(ViewTreeAppTest, ReorderView) {
+TEST_F(WindowTreeAppTest, ReorderWindow) {
ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
- Id view_2_1 = vm_client2()->CreateView(1);
- Id view_2_2 = vm_client2()->CreateView(2);
- Id view_2_3 = vm_client2()->CreateView(3);
- Id view_1_4 = vm_client1()->CreateView(4); // Peer to 1,1
- Id view_1_5 = vm_client1()->CreateView(5); // Peer to 1,1
- Id view_2_6 = vm_client2()->CreateView(6); // Child of 1,2.
- Id view_2_7 = vm_client2()->CreateView(7); // Unparented.
- Id view_2_8 = vm_client2()->CreateView(8); // Unparented.
+ Id view_2_1 = vm_client2()->NewWindow(1);
+ Id view_2_2 = vm_client2()->NewWindow(2);
+ Id view_2_3 = vm_client2()->NewWindow(3);
+ Id view_1_4 = vm_client1()->NewWindow(4); // Peer to 1,1
+ Id view_1_5 = vm_client1()->NewWindow(5); // Peer to 1,1
+ Id view_2_6 = vm_client2()->NewWindow(6); // Child of 1,2.
+ Id view_2_7 = vm_client2()->NewWindow(7); // Unparented.
+ Id view_2_8 = vm_client2()->NewWindow(8); // Unparented.
ASSERT_TRUE(view_2_1);
ASSERT_TRUE(view_2_2);
ASSERT_TRUE(view_2_3);
@@ -929,16 +932,17 @@ TEST_F(ViewTreeAppTest, ReorderView) {
ASSERT_TRUE(view_2_7);
ASSERT_TRUE(view_2_8);
- ASSERT_TRUE(AddView(vm2(), view_2_1, view_2_2));
- ASSERT_TRUE(AddView(vm2(), view_2_2, view_2_6));
- ASSERT_TRUE(AddView(vm2(), view_2_1, view_2_3));
- ASSERT_TRUE(AddView(vm1(), root_view_id(), view_1_4));
- ASSERT_TRUE(AddView(vm1(), root_view_id(), view_1_5));
- ASSERT_TRUE(AddView(vm1(), root_view_id(), view_2_1));
+ ASSERT_TRUE(AddWindow(vm2(), view_2_1, view_2_2));
+ ASSERT_TRUE(AddWindow(vm2(), view_2_2, view_2_6));
+ ASSERT_TRUE(AddWindow(vm2(), view_2_1, view_2_3));
+ ASSERT_TRUE(AddWindow(vm1(), root_window_id(), view_1_4));
+ ASSERT_TRUE(AddWindow(vm1(), root_window_id(), view_1_5));
+ ASSERT_TRUE(AddWindow(vm1(), root_window_id(), view_2_1));
{
changes1()->clear();
- ASSERT_TRUE(ReorderView(vm2(), view_2_2, view_2_3, ORDER_DIRECTION_ABOVE));
+ ASSERT_TRUE(
+ ReorderWindow(vm2(), view_2_2, view_2_3, mojom::ORDER_DIRECTION_ABOVE));
vm_client1_->WaitForChangeCount(1);
EXPECT_EQ("Reordered view=" + IdToString(view_2_2) + " relative=" +
@@ -948,7 +952,8 @@ TEST_F(ViewTreeAppTest, ReorderView) {
{
changes1()->clear();
- ASSERT_TRUE(ReorderView(vm2(), view_2_2, view_2_3, ORDER_DIRECTION_BELOW));
+ ASSERT_TRUE(
+ ReorderWindow(vm2(), view_2_2, view_2_3, mojom::ORDER_DIRECTION_BELOW));
vm_client1_->WaitForChangeCount(1);
EXPECT_EQ("Reordered view=" + IdToString(view_2_2) + " relative=" +
@@ -957,34 +962,38 @@ TEST_F(ViewTreeAppTest, ReorderView) {
}
// view2 is already below view3.
- EXPECT_FALSE(ReorderView(vm2(), view_2_2, view_2_3, ORDER_DIRECTION_BELOW));
+ EXPECT_FALSE(
+ ReorderWindow(vm2(), view_2_2, view_2_3, mojom::ORDER_DIRECTION_BELOW));
// view4 & 5 are unknown to connection2_.
- EXPECT_FALSE(ReorderView(vm2(), view_1_4, view_1_5, ORDER_DIRECTION_ABOVE));
+ EXPECT_FALSE(
+ ReorderWindow(vm2(), view_1_4, view_1_5, mojom::ORDER_DIRECTION_ABOVE));
// view6 & view3 have different parents.
- EXPECT_FALSE(ReorderView(vm1(), view_2_3, view_2_6, ORDER_DIRECTION_ABOVE));
+ EXPECT_FALSE(
+ ReorderWindow(vm1(), view_2_3, view_2_6, mojom::ORDER_DIRECTION_ABOVE));
// Non-existent view-ids
- EXPECT_FALSE(ReorderView(vm1(), BuildViewId(connection_id_1(), 27),
- BuildViewId(connection_id_1(), 28),
- ORDER_DIRECTION_ABOVE));
+ EXPECT_FALSE(ReorderWindow(vm1(), BuildViewId(connection_id_1(), 27),
+ BuildViewId(connection_id_1(), 28),
+ mojom::ORDER_DIRECTION_ABOVE));
// view7 & view8 are un-parented.
- EXPECT_FALSE(ReorderView(vm1(), view_2_7, view_2_8, ORDER_DIRECTION_ABOVE));
+ EXPECT_FALSE(
+ ReorderWindow(vm1(), view_2_7, view_2_8, mojom::ORDER_DIRECTION_ABOVE));
}
-// Verifies DeleteView works.
-TEST_F(ViewTreeAppTest, DeleteView) {
+// Verifies DeleteWindow works.
+TEST_F(WindowTreeAppTest, DeleteWindow) {
ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
Id view_1_1 = BuildViewId(connection_id_1(), 1);
- Id view_2_2 = vm_client2()->CreateView(2);
+ Id view_2_2 = vm_client2()->NewWindow(2);
ASSERT_TRUE(view_2_2);
// Make 2 a child of 1.
{
changes1()->clear();
- ASSERT_TRUE(AddView(vm2(), view_1_1, view_2_2));
+ ASSERT_TRUE(AddWindow(vm2(), view_1_1, view_2_2));
vm_client1_->WaitForChangeCount(1);
EXPECT_EQ("HierarchyChanged view=" + IdToString(view_2_2) + " new_parent=" +
IdToString(view_1_1) + " old_parent=null",
@@ -995,7 +1004,7 @@ TEST_F(ViewTreeAppTest, DeleteView) {
{
changes1()->clear();
changes2()->clear();
- ASSERT_TRUE(DeleteView(vm2(), view_2_2));
+ ASSERT_TRUE(DeleteWindow(vm2(), view_2_2));
EXPECT_TRUE(changes2()->empty());
vm_client1_->WaitForChangeCount(1);
@@ -1004,24 +1013,24 @@ TEST_F(ViewTreeAppTest, DeleteView) {
}
}
-// Verifies DeleteView isn't allowed from a separate connection.
-TEST_F(ViewTreeAppTest, DeleteViewFromAnotherConnectionDisallowed) {
+// Verifies DeleteWindow isn't allowed from a separate connection.
+TEST_F(WindowTreeAppTest, DeleteWindowFromAnotherConnectionDisallowed) {
ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
- EXPECT_FALSE(DeleteView(vm2(), BuildViewId(connection_id_1(), 1)));
+ EXPECT_FALSE(DeleteWindow(vm2(), BuildViewId(connection_id_1(), 1)));
}
// Verifies if a view was deleted and then reused that other clients are
// properly notified.
-TEST_F(ViewTreeAppTest, ReuseDeletedViewId) {
+TEST_F(WindowTreeAppTest, ReuseDeletedViewId) {
ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
Id view_1_1 = BuildViewId(connection_id_1(), 1);
- Id view_2_2 = vm_client2()->CreateView(2);
+ Id view_2_2 = vm_client2()->NewWindow(2);
ASSERT_TRUE(view_2_2);
// Add 2 to 1.
{
changes1()->clear();
- ASSERT_TRUE(AddView(vm2(), view_1_1, view_2_2));
+ ASSERT_TRUE(AddWindow(vm2(), view_1_1, view_2_2));
vm_client1_->WaitForChangeCount(1);
EXPECT_EQ("HierarchyChanged view=" + IdToString(view_2_2) + " new_parent=" +
IdToString(view_1_1) + " old_parent=null",
@@ -1033,7 +1042,7 @@ TEST_F(ViewTreeAppTest, ReuseDeletedViewId) {
// Delete 2.
{
changes1()->clear();
- ASSERT_TRUE(DeleteView(vm2(), view_2_2));
+ ASSERT_TRUE(DeleteWindow(vm2(), view_2_2));
vm_client1_->WaitForChangeCount(1);
EXPECT_EQ("ViewDeleted view=" + IdToString(view_2_2),
@@ -1041,11 +1050,11 @@ TEST_F(ViewTreeAppTest, ReuseDeletedViewId) {
}
// Create 2 again, and add it back to 1. Should get the same notification.
- view_2_2 = vm_client2()->CreateView(2);
+ view_2_2 = vm_client2()->NewWindow(2);
ASSERT_TRUE(view_2_2);
{
changes1()->clear();
- ASSERT_TRUE(AddView(vm2(), view_1_1, view_2_2));
+ ASSERT_TRUE(AddWindow(vm2(), view_1_1, view_2_2));
vm_client1_->WaitForChangeCount(1);
EXPECT_EQ("HierarchyChanged view=" + IdToString(view_2_2) + " new_parent=" +
@@ -1056,44 +1065,44 @@ TEST_F(ViewTreeAppTest, ReuseDeletedViewId) {
}
}
-// Assertions for GetViewTree.
-TEST_F(ViewTreeAppTest, GetViewTree) {
+// Assertions for GetWindowTree.
+TEST_F(WindowTreeAppTest, GetWindowTree) {
ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
Id view_1_1 = BuildViewId(connection_id_1(), 1);
// Create 11 in first connection and make it a child of 1.
- Id view_1_11 = vm_client1()->CreateView(11);
+ Id view_1_11 = vm_client1()->NewWindow(11);
ASSERT_TRUE(view_1_11);
- ASSERT_TRUE(AddView(vm1(), root_view_id(), view_1_1));
- ASSERT_TRUE(AddView(vm1(), view_1_1, view_1_11));
+ ASSERT_TRUE(AddWindow(vm1(), root_window_id(), view_1_1));
+ ASSERT_TRUE(AddWindow(vm1(), view_1_1, view_1_11));
// Create two views in second connection, 2 and 3, both children of 1.
- Id view_2_2 = vm_client2()->CreateView(2);
- Id view_2_3 = vm_client2()->CreateView(3);
+ Id view_2_2 = vm_client2()->NewWindow(2);
+ Id view_2_3 = vm_client2()->NewWindow(3);
ASSERT_TRUE(view_2_2);
ASSERT_TRUE(view_2_3);
- ASSERT_TRUE(AddView(vm2(), view_1_1, view_2_2));
- ASSERT_TRUE(AddView(vm2(), view_1_1, view_2_3));
+ ASSERT_TRUE(AddWindow(vm2(), view_1_1, view_2_2));
+ ASSERT_TRUE(AddWindow(vm2(), view_1_1, view_2_3));
- // Verifies GetViewTree() on the root. The root connection sees all.
+ // Verifies GetWindowTree() on the root. The root connection sees all.
{
std::vector<TestView> views;
- GetViewTree(vm1(), root_view_id(), &views);
+ GetWindowTree(vm1(), root_window_id(), &views);
ASSERT_EQ(5u, views.size());
- EXPECT_EQ(ViewParentToString(root_view_id(), kNullParentId),
+ EXPECT_EQ(ViewParentToString(root_window_id(), kNullParentId),
views[0].ToString());
- EXPECT_EQ(ViewParentToString(view_1_1, root_view_id()),
+ EXPECT_EQ(ViewParentToString(view_1_1, root_window_id()),
views[1].ToString());
EXPECT_EQ(ViewParentToString(view_1_11, view_1_1), views[2].ToString());
EXPECT_EQ(ViewParentToString(view_2_2, view_1_1), views[3].ToString());
EXPECT_EQ(ViewParentToString(view_2_3, view_1_1), views[4].ToString());
}
- // Verifies GetViewTree() on the view 1,1 from vm2(). vm2() sees 1,1 as 1,1
+ // Verifies GetWindowTree() on the view 1,1 from vm2(). vm2() sees 1,1 as 1,1
// is vm2()'s root and vm2() sees all the views it created.
{
std::vector<TestView> views;
- GetViewTree(vm2(), view_1_1, &views);
+ GetWindowTree(vm2(), view_1_1, &views);
ASSERT_EQ(3u, views.size());
EXPECT_EQ(ViewParentToString(view_1_1, kNullParentId), views[0].ToString());
EXPECT_EQ(ViewParentToString(view_2_2, view_1_1), views[1].ToString());
@@ -1103,20 +1112,20 @@ TEST_F(ViewTreeAppTest, GetViewTree) {
// Connection 2 shouldn't be able to get the root tree.
{
std::vector<TestView> views;
- GetViewTree(vm2(), root_view_id(), &views);
+ GetWindowTree(vm2(), root_window_id(), &views);
ASSERT_EQ(0u, views.size());
}
}
-TEST_F(ViewTreeAppTest, SetViewBounds) {
- Id view_1_1 = vm_client1()->CreateView(1);
+TEST_F(WindowTreeAppTest, SetWindowBounds) {
+ Id view_1_1 = vm_client1()->NewWindow(1);
ASSERT_TRUE(view_1_1);
- ASSERT_TRUE(AddView(vm1(), root_view_id(), view_1_1));
+ ASSERT_TRUE(AddWindow(vm1(), root_window_id(), view_1_1));
ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false));
changes2()->clear();
- ASSERT_TRUE(SetViewBounds(vm1(), view_1_1, 0, 0, 100, 100));
+ ASSERT_TRUE(SetWindowBounds(vm1(), view_1_1, 0, 0, 100, 100));
vm_client2_->WaitForChangeCount(1);
EXPECT_EQ("BoundsChanged view=" + IdToString(view_1_1) +
@@ -1125,14 +1134,14 @@ TEST_F(ViewTreeAppTest, SetViewBounds) {
// Should not be possible to change the bounds of a view created by another
// connection.
- ASSERT_FALSE(SetViewBounds(vm2(), view_1_1, 0, 0, 0, 0));
+ ASSERT_FALSE(SetWindowBounds(vm2(), view_1_1, 0, 0, 0, 0));
}
-// Verify AddView fails when trying to manipulate views in other roots.
-TEST_F(ViewTreeAppTest, CantMoveViewsFromOtherRoot) {
+// Verify AddWindow fails when trying to manipulate views in other roots.
+TEST_F(WindowTreeAppTest, CantMoveViewsFromOtherRoot) {
// Create 1 and 2 in the first connection.
- Id view_1_1 = vm_client1()->CreateView(1);
- Id view_1_2 = vm_client1()->CreateView(2);
+ Id view_1_1 = vm_client1()->NewWindow(1);
+ Id view_1_2 = vm_client1()->NewWindow(2);
ASSERT_TRUE(view_1_1);
ASSERT_TRUE(view_1_2);
@@ -1140,87 +1149,87 @@ TEST_F(ViewTreeAppTest, CantMoveViewsFromOtherRoot) {
// Try to move 2 to be a child of 1 from connection 2. This should fail as 2
// should not be able to access 1.
- ASSERT_FALSE(AddView(vm2(), view_1_1, view_1_2));
+ ASSERT_FALSE(AddWindow(vm2(), view_1_1, view_1_2));
// Try to reparent 1 to the root. A connection is not allowed to reparent its
// roots.
- ASSERT_FALSE(AddView(vm2(), root_view_id(), view_1_1));
+ ASSERT_FALSE(AddWindow(vm2(), root_window_id(), view_1_1));
}
-// Verify RemoveViewFromParent fails for views that are descendants of the
+// Verify RemoveWindowFromParent fails for views that are descendants of the
// roots.
-TEST_F(ViewTreeAppTest, CantRemoveViewsInOtherRoots) {
+TEST_F(WindowTreeAppTest, CantRemoveWindowsInOtherRoots) {
// Create 1 and 2 in the first connection and parent both to the root.
- Id view_1_1 = vm_client1()->CreateView(1);
- Id view_1_2 = vm_client1()->CreateView(2);
+ Id view_1_1 = vm_client1()->NewWindow(1);
+ Id view_1_2 = vm_client1()->NewWindow(2);
ASSERT_TRUE(view_1_1);
ASSERT_TRUE(view_1_2);
- ASSERT_TRUE(AddView(vm1(), root_view_id(), view_1_1));
- ASSERT_TRUE(AddView(vm1(), root_view_id(), view_1_2));
+ ASSERT_TRUE(AddWindow(vm1(), root_window_id(), view_1_1));
+ ASSERT_TRUE(AddWindow(vm1(), root_window_id(), view_1_2));
// Establish the second connection and give it the root 1.
ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false));
// Connection 2 should not be able to remove view 2 or 1 from its parent.
- ASSERT_FALSE(RemoveViewFromParent(vm2(), view_1_2));
- ASSERT_FALSE(RemoveViewFromParent(vm2(), view_1_1));
+ ASSERT_FALSE(RemoveWindowFromParent(vm2(), view_1_2));
+ ASSERT_FALSE(RemoveWindowFromParent(vm2(), view_1_1));
// Create views 10 and 11 in 2.
- Id view_2_10 = vm_client2()->CreateView(10);
- Id view_2_11 = vm_client2()->CreateView(11);
+ Id view_2_10 = vm_client2()->NewWindow(10);
+ Id view_2_11 = vm_client2()->NewWindow(11);
ASSERT_TRUE(view_2_10);
ASSERT_TRUE(view_2_11);
// Parent 11 to 10.
- ASSERT_TRUE(AddView(vm2(), view_2_10, view_2_11));
+ ASSERT_TRUE(AddWindow(vm2(), view_2_10, view_2_11));
// Remove 11 from 10.
- ASSERT_TRUE(RemoveViewFromParent(vm2(), view_2_11));
+ ASSERT_TRUE(RemoveWindowFromParent(vm2(), view_2_11));
// Verify nothing was actually removed.
{
std::vector<TestView> views;
- GetViewTree(vm1(), root_view_id(), &views);
+ GetWindowTree(vm1(), root_window_id(), &views);
ASSERT_EQ(3u, views.size());
- EXPECT_EQ(ViewParentToString(root_view_id(), kNullParentId),
+ EXPECT_EQ(ViewParentToString(root_window_id(), kNullParentId),
views[0].ToString());
- EXPECT_EQ(ViewParentToString(view_1_1, root_view_id()),
+ EXPECT_EQ(ViewParentToString(view_1_1, root_window_id()),
views[1].ToString());
- EXPECT_EQ(ViewParentToString(view_1_2, root_view_id()),
+ EXPECT_EQ(ViewParentToString(view_1_2, root_window_id()),
views[2].ToString());
}
}
-// Verify GetViewTree fails for views that are not descendants of the roots.
-TEST_F(ViewTreeAppTest, CantGetViewTreeOfOtherRoots) {
+// Verify GetWindowTree fails for views that are not descendants of the roots.
+TEST_F(WindowTreeAppTest, CantGetWindowTreeOfOtherRoots) {
// Create 1 and 2 in the first connection and parent both to the root.
- Id view_1_1 = vm_client1()->CreateView(1);
- Id view_1_2 = vm_client1()->CreateView(2);
+ Id view_1_1 = vm_client1()->NewWindow(1);
+ Id view_1_2 = vm_client1()->NewWindow(2);
ASSERT_TRUE(view_1_1);
ASSERT_TRUE(view_1_2);
- ASSERT_TRUE(AddView(vm1(), root_view_id(), view_1_1));
- ASSERT_TRUE(AddView(vm1(), root_view_id(), view_1_2));
+ ASSERT_TRUE(AddWindow(vm1(), root_window_id(), view_1_1));
+ ASSERT_TRUE(AddWindow(vm1(), root_window_id(), view_1_2));
ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false));
std::vector<TestView> views;
// Should get nothing for the root.
- GetViewTree(vm2(), root_view_id(), &views);
+ GetWindowTree(vm2(), root_window_id(), &views);
ASSERT_TRUE(views.empty());
// Should get nothing for view 2.
- GetViewTree(vm2(), view_1_2, &views);
+ GetWindowTree(vm2(), view_1_2, &views);
ASSERT_TRUE(views.empty());
// Should get view 1 if asked for.
- GetViewTree(vm2(), view_1_1, &views);
+ GetWindowTree(vm2(), view_1_1, &views);
ASSERT_EQ(1u, views.size());
EXPECT_EQ(ViewParentToString(view_1_1, kNullParentId), views[0].ToString());
}
-TEST_F(ViewTreeAppTest, EmbedWithSameViewId) {
+TEST_F(WindowTreeAppTest, EmbedWithSameViewId) {
ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
changes2()->clear();
@@ -1238,12 +1247,12 @@ TEST_F(ViewTreeAppTest, EmbedWithSameViewId) {
// Connection2 has no root. Verify it can't see view 1,1 anymore.
{
std::vector<TestView> views;
- GetViewTree(vm2(), view_1_1, &views);
+ GetWindowTree(vm2(), view_1_1, &views);
EXPECT_TRUE(views.empty());
}
}
-TEST_F(ViewTreeAppTest, EmbedWithSameViewId2) {
+TEST_F(WindowTreeAppTest, EmbedWithSameViewId2) {
ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
Id view_1_1 = BuildViewId(connection_id_1(), 1);
changes2()->clear();
@@ -1255,9 +1264,9 @@ TEST_F(ViewTreeAppTest, EmbedWithSameViewId2) {
changes2()->clear();
// Create a view in the third connection and parent it to the root.
- Id view_3_1 = vm_client3()->CreateView(1);
+ Id view_3_1 = vm_client3()->NewWindow(1);
ASSERT_TRUE(view_3_1);
- ASSERT_TRUE(AddView(vm3(), view_1_1, view_3_1));
+ ASSERT_TRUE(AddWindow(vm3(), view_1_1, view_3_1));
// Connection 1 should have been told about the add (it owns the view).
{
@@ -1272,7 +1281,7 @@ TEST_F(ViewTreeAppTest, EmbedWithSameViewId2) {
changes3()->clear();
// We should get a new connection for the new embedding.
- scoped_ptr<TestViewTreeClientImpl> connection4(
+ scoped_ptr<TestWindowTreeClientImpl> connection4(
EstablishConnectionViaEmbed(vm1(), view_1_1, nullptr));
ASSERT_TRUE(connection4.get());
EXPECT_EQ("[" + ViewParentToString(view_1_1, kNullParentId) + "]",
@@ -1288,7 +1297,7 @@ TEST_F(ViewTreeAppTest, EmbedWithSameViewId2) {
// vm3() has no root. Verify it can't see view 1,1 anymore.
{
std::vector<TestView> views;
- GetViewTree(vm3(), view_1_1, &views);
+ GetWindowTree(vm3(), view_1_1, &views);
EXPECT_TRUE(views.empty());
}
@@ -1296,7 +1305,7 @@ TEST_F(ViewTreeAppTest, EmbedWithSameViewId2) {
// vm3() can no longer see 1,1.
{
std::vector<TestView> views;
- GetViewTree(vm1(), view_1_1, &views);
+ GetWindowTree(vm1(), view_1_1, &views);
ASSERT_EQ(1u, views.size());
EXPECT_EQ(ViewParentToString(view_1_1, kNullParentId), views[0].ToString());
}
@@ -1304,66 +1313,66 @@ TEST_F(ViewTreeAppTest, EmbedWithSameViewId2) {
// Verify vm3() can still see the view it created 3,1.
{
std::vector<TestView> views;
- GetViewTree(vm3(), view_3_1, &views);
+ GetWindowTree(vm3(), view_3_1, &views);
ASSERT_EQ(1u, views.size());
EXPECT_EQ(ViewParentToString(view_3_1, kNullParentId), views[0].ToString());
}
}
-// Assertions for SetViewVisibility.
-TEST_F(ViewTreeAppTest, SetViewVisibility) {
+// Assertions for SetWindowVisibility.
+TEST_F(WindowTreeAppTest, SetWindowVisibility) {
// Create 1 and 2 in the first connection and parent both to the root.
- Id view_1_1 = vm_client1()->CreateView(1);
- Id view_1_2 = vm_client1()->CreateView(2);
+ Id view_1_1 = vm_client1()->NewWindow(1);
+ Id view_1_2 = vm_client1()->NewWindow(2);
ASSERT_TRUE(view_1_1);
ASSERT_TRUE(view_1_2);
- ASSERT_TRUE(AddView(vm1(), root_view_id(), view_1_1));
+ ASSERT_TRUE(AddWindow(vm1(), root_window_id(), view_1_1));
{
std::vector<TestView> views;
- GetViewTree(vm1(), root_view_id(), &views);
+ GetWindowTree(vm1(), root_window_id(), &views);
ASSERT_EQ(2u, views.size());
- EXPECT_EQ(ViewParentToString(root_view_id(), kNullParentId) +
+ EXPECT_EQ(ViewParentToString(root_window_id(), kNullParentId) +
" visible=true drawn=true",
views[0].ToString2());
- EXPECT_EQ(ViewParentToString(view_1_1, root_view_id()) +
+ EXPECT_EQ(ViewParentToString(view_1_1, root_window_id()) +
" visible=false drawn=false",
views[1].ToString2());
}
// Show all the views.
- ASSERT_TRUE(SetViewVisibility(vm1(), view_1_1, true));
- ASSERT_TRUE(SetViewVisibility(vm1(), view_1_2, true));
+ ASSERT_TRUE(SetWindowVisibility(vm1(), view_1_1, true));
+ ASSERT_TRUE(SetWindowVisibility(vm1(), view_1_2, true));
{
std::vector<TestView> views;
- GetViewTree(vm1(), root_view_id(), &views);
+ GetWindowTree(vm1(), root_window_id(), &views);
ASSERT_EQ(2u, views.size());
- EXPECT_EQ(ViewParentToString(root_view_id(), kNullParentId) +
+ EXPECT_EQ(ViewParentToString(root_window_id(), kNullParentId) +
" visible=true drawn=true",
views[0].ToString2());
- EXPECT_EQ(ViewParentToString(view_1_1, root_view_id()) +
+ EXPECT_EQ(ViewParentToString(view_1_1, root_window_id()) +
" visible=true drawn=true",
views[1].ToString2());
}
// Hide 1.
- ASSERT_TRUE(SetViewVisibility(vm1(), view_1_1, false));
+ ASSERT_TRUE(SetWindowVisibility(vm1(), view_1_1, false));
{
std::vector<TestView> views;
- GetViewTree(vm1(), view_1_1, &views);
+ GetWindowTree(vm1(), view_1_1, &views);
ASSERT_EQ(1u, views.size());
- EXPECT_EQ(ViewParentToString(view_1_1, root_view_id()) +
+ EXPECT_EQ(ViewParentToString(view_1_1, root_window_id()) +
" visible=false drawn=false",
views[0].ToString2());
}
// Attach 2 to 1.
- ASSERT_TRUE(AddView(vm1(), view_1_1, view_1_2));
+ ASSERT_TRUE(AddWindow(vm1(), view_1_1, view_1_2));
{
std::vector<TestView> views;
- GetViewTree(vm1(), view_1_1, &views);
+ GetWindowTree(vm1(), view_1_1, &views);
ASSERT_EQ(2u, views.size());
- EXPECT_EQ(ViewParentToString(view_1_1, root_view_id()) +
+ EXPECT_EQ(ViewParentToString(view_1_1, root_window_id()) +
" visible=false drawn=false",
views[0].ToString2());
EXPECT_EQ(
@@ -1372,12 +1381,12 @@ TEST_F(ViewTreeAppTest, SetViewVisibility) {
}
// Show 1.
- ASSERT_TRUE(SetViewVisibility(vm1(), view_1_1, true));
+ ASSERT_TRUE(SetWindowVisibility(vm1(), view_1_1, true));
{
std::vector<TestView> views;
- GetViewTree(vm1(), view_1_1, &views);
+ GetWindowTree(vm1(), view_1_1, &views);
ASSERT_EQ(2u, views.size());
- EXPECT_EQ(ViewParentToString(view_1_1, root_view_id()) +
+ EXPECT_EQ(ViewParentToString(view_1_1, root_window_id()) +
" visible=true drawn=true",
views[0].ToString2());
EXPECT_EQ(
@@ -1386,31 +1395,31 @@ TEST_F(ViewTreeAppTest, SetViewVisibility) {
}
}
-// Assertions for SetViewVisibility sending notifications.
-TEST_F(ViewTreeAppTest, SetViewVisibilityNotifications) {
+// Assertions for SetWindowVisibility sending notifications.
+TEST_F(WindowTreeAppTest, SetWindowVisibilityNotifications) {
// Create 1,1 and 1,2. 1,2 is made a child of 1,1 and 1,1 a child of the root.
- Id view_1_1 = vm_client1()->CreateView(1);
+ Id view_1_1 = vm_client1()->NewWindow(1);
ASSERT_TRUE(view_1_1);
- ASSERT_TRUE(SetViewVisibility(vm1(), view_1_1, true));
- Id view_1_2 = vm_client1()->CreateView(2);
+ ASSERT_TRUE(SetWindowVisibility(vm1(), view_1_1, true));
+ Id view_1_2 = vm_client1()->NewWindow(2);
ASSERT_TRUE(view_1_2);
- ASSERT_TRUE(SetViewVisibility(vm1(), view_1_2, true));
- ASSERT_TRUE(AddView(vm1(), root_view_id(), view_1_1));
- ASSERT_TRUE(AddView(vm1(), view_1_1, view_1_2));
+ ASSERT_TRUE(SetWindowVisibility(vm1(), view_1_2, true));
+ ASSERT_TRUE(AddWindow(vm1(), root_window_id(), view_1_1));
+ ASSERT_TRUE(AddWindow(vm1(), view_1_1, view_1_2));
// Establish the second connection at 1,2.
ASSERT_NO_FATAL_FAILURE(EstablishSecondConnectionWithRoot(view_1_2));
// Add 2,3 as a child of 1,2.
- Id view_2_3 = vm_client2()->CreateView(3);
+ Id view_2_3 = vm_client2()->NewWindow(3);
ASSERT_TRUE(view_2_3);
- ASSERT_TRUE(SetViewVisibility(vm2(), view_2_3, true));
- ASSERT_TRUE(AddView(vm2(), view_1_2, view_2_3));
+ ASSERT_TRUE(SetWindowVisibility(vm2(), view_2_3, true));
+ ASSERT_TRUE(AddWindow(vm2(), view_1_2, view_2_3));
WaitForAllMessages(vm1());
changes2()->clear();
// Hide 1,2 from connection 1. Connection 2 should see this.
- ASSERT_TRUE(SetViewVisibility(vm1(), view_1_2, false));
+ ASSERT_TRUE(SetWindowVisibility(vm1(), view_1_2, false));
{
vm_client2_->WaitForChangeCount(1);
EXPECT_EQ(
@@ -1420,7 +1429,7 @@ TEST_F(ViewTreeAppTest, SetViewVisibilityNotifications) {
changes1()->clear();
// Show 1,2 from connection 2, connection 1 should be notified.
- ASSERT_TRUE(SetViewVisibility(vm2(), view_1_2, true));
+ ASSERT_TRUE(SetWindowVisibility(vm2(), view_1_2, true));
{
vm_client1_->WaitForChangeCount(1);
EXPECT_EQ(
@@ -1430,7 +1439,7 @@ TEST_F(ViewTreeAppTest, SetViewVisibilityNotifications) {
changes2()->clear();
// Hide 1,1, connection 2 should be told the draw state changed.
- ASSERT_TRUE(SetViewVisibility(vm1(), view_1_1, false));
+ ASSERT_TRUE(SetWindowVisibility(vm1(), view_1_1, false));
{
vm_client2_->WaitForChangeCount(1);
EXPECT_EQ("DrawnStateChanged view=" + IdToString(view_1_2) + " drawn=false",
@@ -1439,7 +1448,7 @@ TEST_F(ViewTreeAppTest, SetViewVisibilityNotifications) {
changes2()->clear();
// Show 1,1 from connection 1. Connection 2 should see this.
- ASSERT_TRUE(SetViewVisibility(vm1(), view_1_1, true));
+ ASSERT_TRUE(SetWindowVisibility(vm1(), view_1_1, true));
{
vm_client2_->WaitForChangeCount(1);
EXPECT_EQ("DrawnStateChanged view=" + IdToString(view_1_2) + " drawn=true",
@@ -1448,7 +1457,7 @@ TEST_F(ViewTreeAppTest, SetViewVisibilityNotifications) {
// Change visibility of 2,3, connection 1 should see this.
changes1()->clear();
- ASSERT_TRUE(SetViewVisibility(vm2(), view_2_3, false));
+ ASSERT_TRUE(SetWindowVisibility(vm2(), view_2_3, false));
{
vm_client1_->WaitForChangeCount(1);
EXPECT_EQ(
@@ -1458,7 +1467,7 @@ TEST_F(ViewTreeAppTest, SetViewVisibilityNotifications) {
changes2()->clear();
// Remove 1,1 from the root, connection 2 should see drawn state changed.
- ASSERT_TRUE(RemoveViewFromParent(vm1(), view_1_1));
+ ASSERT_TRUE(RemoveWindowFromParent(vm1(), view_1_1));
{
vm_client2_->WaitForChangeCount(1);
EXPECT_EQ("DrawnStateChanged view=" + IdToString(view_1_2) + " drawn=false",
@@ -1467,7 +1476,7 @@ TEST_F(ViewTreeAppTest, SetViewVisibilityNotifications) {
changes2()->clear();
// Add 1,1 back to the root, connection 2 should see drawn state changed.
- ASSERT_TRUE(AddView(vm1(), root_view_id(), view_1_1));
+ ASSERT_TRUE(AddWindow(vm1(), root_window_id(), view_1_1));
{
vm_client2_->WaitForChangeCount(1);
EXPECT_EQ("DrawnStateChanged view=" + IdToString(view_1_2) + " drawn=true",
@@ -1475,27 +1484,27 @@ TEST_F(ViewTreeAppTest, SetViewVisibilityNotifications) {
}
}
-TEST_F(ViewTreeAppTest, SetViewProperty) {
- Id view_1_1 = vm_client1()->CreateView(1);
+TEST_F(WindowTreeAppTest, SetWindowProperty) {
+ Id view_1_1 = vm_client1()->NewWindow(1);
ASSERT_TRUE(view_1_1);
ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false));
changes2()->clear();
- ASSERT_TRUE(AddView(vm1(), root_view_id(), view_1_1));
+ ASSERT_TRUE(AddWindow(vm1(), root_window_id(), view_1_1));
{
std::vector<TestView> views;
- GetViewTree(vm1(), root_view_id(), &views);
+ GetWindowTree(vm1(), root_window_id(), &views);
ASSERT_EQ(2u, views.size());
- EXPECT_EQ(root_view_id(), views[0].view_id);
- EXPECT_EQ(view_1_1, views[1].view_id);
+ EXPECT_EQ(root_window_id(), views[0].window_id);
+ EXPECT_EQ(view_1_1, views[1].window_id);
ASSERT_EQ(0u, views[1].properties.size());
}
// Set properties on 1.
changes2()->clear();
std::vector<uint8_t> one(1, '1');
- ASSERT_TRUE(SetViewProperty(vm1(), view_1_1, "one", &one));
+ ASSERT_TRUE(SetWindowProperty(vm1(), view_1_1, "one", &one));
{
vm_client2_->WaitForChangeCount(1);
EXPECT_EQ(
@@ -1506,7 +1515,7 @@ TEST_F(ViewTreeAppTest, SetViewProperty) {
// Test that our properties exist in the view tree
{
std::vector<TestView> views;
- GetViewTree(vm1(), view_1_1, &views);
+ GetWindowTree(vm1(), view_1_1, &views);
ASSERT_EQ(1u, views.size());
ASSERT_EQ(1u, views[0].properties.size());
EXPECT_EQ(one, views[0].properties["one"]);
@@ -1514,7 +1523,7 @@ TEST_F(ViewTreeAppTest, SetViewProperty) {
changes2()->clear();
// Set back to null.
- ASSERT_TRUE(SetViewProperty(vm1(), view_1_1, "one", NULL));
+ ASSERT_TRUE(SetWindowProperty(vm1(), view_1_1, "one", NULL));
{
vm_client2_->WaitForChangeCount(1);
EXPECT_EQ(
@@ -1523,13 +1532,13 @@ TEST_F(ViewTreeAppTest, SetViewProperty) {
}
}
-TEST_F(ViewTreeAppTest, OnEmbeddedAppDisconnected) {
+TEST_F(WindowTreeAppTest, OnEmbeddedAppDisconnected) {
// Create connection 2 and 3.
ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
Id view_1_1 = BuildViewId(connection_id_1(), 1);
- Id view_2_2 = vm_client2()->CreateView(2);
+ Id view_2_2 = vm_client2()->NewWindow(2);
ASSERT_TRUE(view_2_2);
- ASSERT_TRUE(AddView(vm2(), view_1_1, view_2_2));
+ ASSERT_TRUE(AddWindow(vm2(), view_1_1, view_2_2));
changes2()->clear();
ASSERT_NO_FATAL_FAILURE(EstablishThirdConnection(vm2(), view_2_2));
@@ -1551,17 +1560,17 @@ TEST_F(ViewTreeAppTest, OnEmbeddedAppDisconnected) {
// Verifies when the parent of an Embed() is destroyed the embedded app gets
// a ViewDeleted (and doesn't trigger a DCHECK).
-TEST_F(ViewTreeAppTest, OnParentOfEmbedDisconnects) {
+TEST_F(WindowTreeAppTest, OnParentOfEmbedDisconnects) {
// Create connection 2 and 3.
ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
Id view_1_1 = BuildViewId(connection_id_1(), 1);
- ASSERT_TRUE(AddView(vm1(), root_view_id(), view_1_1));
- Id view_2_2 = vm_client2()->CreateView(2);
- Id view_2_3 = vm_client2()->CreateView(3);
+ ASSERT_TRUE(AddWindow(vm1(), root_window_id(), view_1_1));
+ Id view_2_2 = vm_client2()->NewWindow(2);
+ Id view_2_3 = vm_client2()->NewWindow(3);
ASSERT_TRUE(view_2_2);
ASSERT_TRUE(view_2_3);
- ASSERT_TRUE(AddView(vm2(), view_1_1, view_2_2));
- ASSERT_TRUE(AddView(vm2(), view_2_2, view_2_3));
+ ASSERT_TRUE(AddWindow(vm2(), view_1_1, view_2_2));
+ ASSERT_TRUE(AddWindow(vm2(), view_2_2, view_2_3));
changes2()->clear();
ASSERT_NO_FATAL_FAILURE(EstablishThirdConnection(vm2(), view_2_3));
changes3()->clear();
@@ -1573,29 +1582,29 @@ TEST_F(ViewTreeAppTest, OnParentOfEmbedDisconnects) {
SingleChangeToDescription(*changes3()));
}
-// Verifies ViewTreeImpl doesn't incorrectly erase from its internal
-// map when a view from another connection with the same view_id is removed.
-TEST_F(ViewTreeAppTest, DontCleanMapOnDestroy) {
+// Verifies WindowTreeImpl doesn't incorrectly erase from its internal
+// map when a view from another connection with the same window_id is removed.
+TEST_F(WindowTreeAppTest, DontCleanMapOnDestroy) {
ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
Id view_1_1 = BuildViewId(connection_id_1(), 1);
- ASSERT_TRUE(vm_client2()->CreateView(1));
+ ASSERT_TRUE(vm_client2()->NewWindow(1));
changes1()->clear();
vm_client2_.reset();
vm_client1_->WaitForChangeCount(1);
EXPECT_EQ("OnEmbeddedAppDisconnected view=" + IdToString(view_1_1),
SingleChangeToDescription(*changes1()));
std::vector<TestView> views;
- GetViewTree(vm1(), view_1_1, &views);
+ GetWindowTree(vm1(), view_1_1, &views);
EXPECT_FALSE(views.empty());
}
-// Verifies Embed() works when supplying a ViewTreeClient.
-TEST_F(ViewTreeAppTest, EmbedSupplyingViewTreeClient) {
- ASSERT_TRUE(vm_client1()->CreateView(1));
+// Verifies Embed() works when supplying a WindowTreeClient.
+TEST_F(WindowTreeAppTest, EmbedSupplyingWindowTreeClient) {
+ ASSERT_TRUE(vm_client1()->NewWindow(1));
- TestViewTreeClientImpl client2(application_impl());
- mojo::ViewTreeClientPtr client2_ptr;
- mojo::Binding<ViewTreeClient> client2_binding(&client2, &client2_ptr);
+ TestWindowTreeClientImpl client2(application_impl());
+ mojom::WindowTreeClientPtr client2_ptr;
+ mojo::Binding<WindowTreeClient> client2_binding(&client2, &client2_ptr);
ASSERT_TRUE(
Embed(vm1(), BuildViewId(connection_id_1(), 1), client2_ptr.Pass()));
client2.WaitForOnEmbed();
@@ -1603,18 +1612,18 @@ TEST_F(ViewTreeAppTest, EmbedSupplyingViewTreeClient) {
SingleChangeToDescription(*client2.tracker()->changes()));
}
-TEST_F(ViewTreeAppTest, EmbedFailsFromOtherConnection) {
+TEST_F(WindowTreeAppTest, EmbedFailsFromOtherConnection) {
ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
Id view_1_1 = BuildViewId(connection_id_1(), 1);
- Id view_2_2 = vm_client2()->CreateView(2);
+ Id view_2_2 = vm_client2()->NewWindow(2);
ASSERT_TRUE(view_2_2);
- ASSERT_TRUE(AddView(vm2(), view_1_1, view_2_2));
+ ASSERT_TRUE(AddWindow(vm2(), view_1_1, view_2_2));
ASSERT_NO_FATAL_FAILURE(EstablishThirdConnection(vm2(), view_2_2));
- Id view_3_3 = vm_client3()->CreateView(3);
+ Id view_3_3 = vm_client3()->NewWindow(3);
ASSERT_TRUE(view_3_3);
- ASSERT_TRUE(AddView(vm3(), view_2_2, view_3_3));
+ ASSERT_TRUE(AddWindow(vm3(), view_2_2, view_3_3));
// 2 should not be able to embed in view_3_3 as view_3_3 was not created by
// 2.
@@ -1623,13 +1632,13 @@ TEST_F(ViewTreeAppTest, EmbedFailsFromOtherConnection) {
}
// Verifies Embed() from window manager on another connections view works.
-TEST_F(ViewTreeAppTest, EmbedFromOtherConnection) {
+TEST_F(WindowTreeAppTest, EmbedFromOtherConnection) {
ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
Id view_1_1 = BuildViewId(connection_id_1(), 1);
- Id view_2_2 = vm_client2()->CreateView(2);
+ Id view_2_2 = vm_client2()->NewWindow(2);
ASSERT_TRUE(view_2_2);
- ASSERT_TRUE(AddView(vm2(), view_1_1, view_2_2));
+ ASSERT_TRUE(AddWindow(vm2(), view_1_1, view_2_2));
changes2()->clear();
@@ -1640,31 +1649,32 @@ TEST_F(ViewTreeAppTest, EmbedFromOtherConnection) {
EXPECT_EQ(std::string(), SingleChangeToDescription(*changes2()));
}
-TEST_F(ViewTreeAppTest, CantEmbedFromConnectionRoot) {
+TEST_F(WindowTreeAppTest, CantEmbedFromConnectionRoot) {
// Shouldn't be able to embed into the root.
ASSERT_FALSE(EmbedUrl(application_impl(), vm1(), application_impl()->url(),
- root_view_id()));
+ root_window_id()));
- // Even though the call above failed a ViewTreeClient was obtained. We need to
+ // Even though the call above failed a WindowTreeClient was obtained. We need
+ // to
// wait for it else we throw off the next connect.
- WaitForViewTreeClient();
+ WaitForWindowTreeClient();
// Don't allow a connection to embed into its own root.
ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
EXPECT_FALSE(EmbedUrl(application_impl(), vm2(), application_impl()->url(),
BuildViewId(connection_id_1(), 1)));
- // Need to wait for a ViewTreeClient for same reason as above.
- WaitForViewTreeClient();
+ // Need to wait for a WindowTreeClient for same reason as above.
+ WaitForWindowTreeClient();
- Id view_1_2 = vm_client1()->CreateView(2);
+ Id view_1_2 = vm_client1()->NewWindow(2);
ASSERT_TRUE(view_1_2);
- ASSERT_TRUE(AddView(vm1(), BuildViewId(connection_id_1(), 1), view_1_2));
+ ASSERT_TRUE(AddWindow(vm1(), BuildViewId(connection_id_1(), 1), view_1_2));
ASSERT_TRUE(vm_client3_.get() == nullptr);
vm_client3_ = EstablishConnectionViaEmbedWithPolicyBitmask(
- vm1(), view_1_2, mojo::ViewTree::ACCESS_POLICY_EMBED_ROOT, nullptr);
+ vm1(), view_1_2, mojom::WindowTree::ACCESS_POLICY_EMBED_ROOT, nullptr);
ASSERT_TRUE(vm_client3_.get() != nullptr);
- vm_client3_->set_root_view(root_view_id());
+ vm_client3_->set_root_view(root_window_id());
// view_1_2 is vm3's root, so even though v3 is an embed root it should not
// be able to Embed into itself.
@@ -1673,7 +1683,7 @@ TEST_F(ViewTreeAppTest, CantEmbedFromConnectionRoot) {
}
// TODO(sky): need to better track changes to initial connection. For example,
-// that SetBounsdViews/AddView and the like don't result in messages to the
+// that SetBounsdViews/AddWindow and the like don't result in messages to the
// originating connection.
// TODO(sky): make sure coverage of what was
« no previous file with comments | « components/mus/ws/view_manager_client_apptest.cc ('k') | components/mus/ws/view_tree_host_connection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698