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

Unified Diff: mojo/services/view_manager/view_manager_unittest.cc

Issue 405163002: Add EmbedRoot to ViewManagerService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 5 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
Index: mojo/services/view_manager/view_manager_unittest.cc
diff --git a/mojo/services/view_manager/view_manager_unittest.cc b/mojo/services/view_manager/view_manager_unittest.cc
index 259079648a04cd2fecdf9a1febf9995da4a6539d..f0aa211c6bc2b8c33bd027fb7b28b6482268565f 100644
--- a/mojo/services/view_manager/view_manager_unittest.cc
+++ b/mojo/services/view_manager/view_manager_unittest.cc
@@ -363,8 +363,8 @@ class TestViewManagerClientConnection
}
virtual void OnFocusChanged(Id gained_focus_id,
Id lost_focus_id) OVERRIDE {}
- virtual void EmbedRoot(const String& url) OVERRIDE {
- tracker_.OnEmbedRoot(url);
+ virtual void Embed(const String& url) OVERRIDE {
+ tracker_.OnEmbed(url);
}
virtual void DispatchOnViewInputEvent(Id view_id,
mojo::EventPtr event) OVERRIDE {
@@ -421,23 +421,24 @@ Id BuildViewId(ConnectionSpecificId connection_id,
return (connection_id << 16) | view_id;
}
-// Callback from EmbedRoot(). |result| is the result of the
+// Callback from Embed(). |result| is the result of the
// Embed() call and |run_loop| the nested RunLoop.
-void EmbedRootCallback(bool* result_cache,
- base::RunLoop* run_loop,
- bool result) {
+void EmbedCallback(bool* result_cache, base::RunLoop* run_loop, bool result) {
*result_cache = result;
run_loop->Quit();
}
-// Responsible for establishing the initial ViewManagerService connection.
+// Embed from an application that does not yet have a view manager connection.
// Blocks until result is determined.
-bool EmbedRoot(ViewManagerInitService* view_manager_init,
- const std::string& url) {
+bool InitEmbed(ViewManagerInitService* view_manager_init,
+ const std::string& url,
+ size_t number_of_calls) {
bool result = false;
base::RunLoop run_loop;
- view_manager_init->EmbedRoot(url, base::Bind(&EmbedRootCallback,
- &result, &run_loop));
+ for (size_t i = 0; i < number_of_calls; ++i) {
+ view_manager_init->Embed(url, base::Bind(&EmbedCallback,
+ &result, &run_loop));
+ }
run_loop.Run();
return result;
}
@@ -464,7 +465,7 @@ class ViewManagerTest : public testing::Test {
test_helper_.service_manager()->ConnectToService(
GURL("mojo:mojo_view_manager"),
&view_manager_init_);
- ASSERT_TRUE(EmbedRoot(view_manager_init_.get(), kTestServiceURL));
+ ASSERT_TRUE(InitEmbed(view_manager_init_.get(), kTestServiceURL, 1));
connection_ = ViewManagerProxy::WaitForInstance();
ASSERT_TRUE(connection_ != NULL);
@@ -520,12 +521,25 @@ class ViewManagerTest : public testing::Test {
DISALLOW_COPY_AND_ASSIGN(ViewManagerTest);
};
-TEST_F(ViewManagerTest, SecondEmbedRoot) {
- ASSERT_TRUE(EmbedRoot(view_manager_init_.get(), kTestServiceURL));
+TEST_F(ViewManagerTest, SecondEmbedRoot_InitService) {
+ ASSERT_TRUE(InitEmbed(view_manager_init_.get(), kTestServiceURL, 1));
+ connection_->DoRunLoopUntilChangesCount(1);
+ EXPECT_EQ(kTestServiceURL, connection_->changes()[0].embed_url);
+}
+
+TEST_F(ViewManagerTest, SecondEmbedRoot_Service) {
+ ASSERT_TRUE(connection_->Embed(BuildNodeId(0, 0), kTestServiceURL));
connection_->DoRunLoopUntilChangesCount(1);
EXPECT_EQ(kTestServiceURL, connection_->changes()[0].embed_url);
}
+TEST_F(ViewManagerTest, MultipleEmbedRootsBeforeWTHReady) {
+ ASSERT_TRUE(InitEmbed(view_manager_init_.get(), kTestServiceURL, 2));
+ connection_->DoRunLoopUntilChangesCount(2);
+ EXPECT_EQ(kTestServiceURL, connection_->changes()[0].embed_url);
+ EXPECT_EQ(kTestServiceURL, connection_->changes()[1].embed_url);
+}
+
// Verifies client gets a valid id.
TEST_F(ViewManagerTest, ValidId) {
// TODO(beng): this should really have the URL of the application that
« no previous file with comments | « mojo/services/view_manager/view_manager_service_impl.cc ('k') | mojo/services/window_manager/window_manager_api_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698