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

Side by Side Diff: ui/aura/mus/window_tree_client_unittest.cc

Issue 2565583002: Revert of Ensure compositor initialized before WindowTreeHost is Shown. (Closed)
Patch Set: Created 4 years 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 unified diff | Download patch
« no previous file with comments | « ui/aura/mus/window_tree_client.cc ('k') | ui/aura/window_tree_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "ui/aura/mus/window_tree_client.h" 5 #include "ui/aura/mus/window_tree_client.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 }; 470 };
471 471
472 } // namespace 472 } // namespace
473 473
474 TEST_F(WindowTreeClientClientTest, InputEventBasic) { 474 TEST_F(WindowTreeClientClientTest, InputEventBasic) {
475 InputEventBasicTestWindowDelegate window_delegate(window_tree()); 475 InputEventBasicTestWindowDelegate window_delegate(window_tree());
476 WindowTreeHostMus window_tree_host(window_tree_client_impl()); 476 WindowTreeHostMus window_tree_host(window_tree_client_impl());
477 Window* top_level = window_tree_host.window(); 477 Window* top_level = window_tree_host.window();
478 const gfx::Rect bounds(0, 0, 100, 100); 478 const gfx::Rect bounds(0, 0, 100, 100);
479 window_tree_host.SetBoundsInPixels(bounds); 479 window_tree_host.SetBoundsInPixels(bounds);
480 window_tree_host.InitHost();
481 window_tree_host.Show(); 480 window_tree_host.Show();
482 EXPECT_EQ(bounds, top_level->bounds()); 481 EXPECT_EQ(bounds, top_level->bounds());
483 EXPECT_EQ(bounds, window_tree_host.GetBoundsInPixels()); 482 EXPECT_EQ(bounds, window_tree_host.GetBoundsInPixels());
484 Window child(&window_delegate); 483 Window child(&window_delegate);
485 child.Init(ui::LAYER_NOT_DRAWN); 484 child.Init(ui::LAYER_NOT_DRAWN);
486 top_level->AddChild(&child); 485 top_level->AddChild(&child);
487 child.SetBounds(gfx::Rect(10, 10, 100, 100)); 486 child.SetBounds(gfx::Rect(10, 10, 100, 100));
488 child.Show(); 487 child.Show();
489 EXPECT_FALSE(window_delegate.got_move()); 488 EXPECT_FALSE(window_delegate.got_move());
490 EXPECT_FALSE(window_delegate.was_acked()); 489 EXPECT_FALSE(window_delegate.was_acked());
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 child.reset(); 706 child.reset();
708 ASSERT_TRUE(window_tree()->AckSingleChangeOfType( 707 ASSERT_TRUE(window_tree()->AckSingleChangeOfType(
709 WindowTreeChangeType::VISIBLE, true)); 708 WindowTreeChangeType::VISIBLE, true));
710 } 709 }
711 710
712 TEST_F(WindowTreeClientClientTest, NewTopLevelWindow) { 711 TEST_F(WindowTreeClientClientTest, NewTopLevelWindow) {
713 const size_t initial_root_count = 712 const size_t initial_root_count =
714 window_tree_client_impl()->GetRoots().size(); 713 window_tree_client_impl()->GetRoots().size();
715 std::unique_ptr<WindowTreeHostMus> window_tree_host = 714 std::unique_ptr<WindowTreeHostMus> window_tree_host =
716 base::MakeUnique<WindowTreeHostMus>(window_tree_client_impl()); 715 base::MakeUnique<WindowTreeHostMus>(window_tree_client_impl());
717 window_tree_host->InitHost();
718 aura::Window* top_level = window_tree_host->window(); 716 aura::Window* top_level = window_tree_host->window();
719 // TODO: need to check WindowTreeHost visibility. 717 // TODO: need to check WindowTreeHost visibility.
720 // EXPECT_TRUE(WindowPrivate(root2).parent_drawn()); 718 // EXPECT_TRUE(WindowPrivate(root2).parent_drawn());
721 EXPECT_NE(server_id(top_level), server_id(root_window())); 719 EXPECT_NE(server_id(top_level), server_id(root_window()));
722 EXPECT_EQ(initial_root_count + 1, 720 EXPECT_EQ(initial_root_count + 1,
723 window_tree_client_impl()->GetRoots().size()); 721 window_tree_client_impl()->GetRoots().size());
724 EXPECT_TRUE(window_tree_client_impl()->GetRoots().count(top_level) > 0u); 722 EXPECT_TRUE(window_tree_client_impl()->GetRoots().count(top_level) > 0u);
725 723
726 // Ack the request to the windowtree to create the new window. 724 // Ack the request to the windowtree to create the new window.
727 uint32_t change_id; 725 uint32_t change_id;
(...skipping 24 matching lines...) Expand all
752 const size_t initial_root_count = 750 const size_t initial_root_count =
753 window_tree_client_impl()->GetRoots().size(); 751 window_tree_client_impl()->GetRoots().size();
754 WindowTreeHostMus window_tree_host(window_tree_client_impl()); 752 WindowTreeHostMus window_tree_host(window_tree_client_impl());
755 Window* top_level = window_tree_host.window(); 753 Window* top_level = window_tree_host.window();
756 EXPECT_EQ(initial_root_count + 1, 754 EXPECT_EQ(initial_root_count + 1,
757 window_tree_client_impl()->GetRoots().size()); 755 window_tree_client_impl()->GetRoots().size());
758 756
759 EXPECT_FALSE(IsWindowHostVisible(top_level)); 757 EXPECT_FALSE(IsWindowHostVisible(top_level));
760 EXPECT_FALSE(top_level->TargetVisibility()); 758 EXPECT_FALSE(top_level->TargetVisibility());
761 759
762 // TODO(mfomitchev): crbug.com/672150 InitHost() currently makes the host
763 // visible, which shouldn't be the case.
764 window_tree_host.InitHost();
765
766 // Ack the request to the windowtree to create the new window. 760 // Ack the request to the windowtree to create the new window.
767 EXPECT_EQ(window_tree()->window_id(), server_id(top_level)); 761 EXPECT_EQ(window_tree()->window_id(), server_id(top_level));
768 762
769 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New(); 763 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New();
770 data->window_id = server_id(top_level); 764 data->window_id = server_id(top_level);
771 data->bounds.SetRect(1, 2, 3, 4); 765 data->bounds.SetRect(1, 2, 3, 4);
772 data->visible = true; 766 data->visible = true;
773 const int64_t display_id = 10; 767 const int64_t display_id = 10;
774 uint32_t change_id; 768 uint32_t change_id;
775 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( 769 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType(
776 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id)); 770 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id));
777 window_tree_client()->OnTopLevelCreated(change_id, std::move(data), 771 window_tree_client()->OnTopLevelCreated(change_id, std::move(data),
778 display_id, true); 772 display_id, true);
779 // TODO(mfomitchev): Uncomment while crbug.com/crbug.com/672150 is fixed 773 EXPECT_EQ(
780 // EXPECT_EQ( 774 0u, window_tree()->GetChangeCountForType(WindowTreeChangeType::VISIBLE));
781 // 0u,
782 // window_tree()->GetChangeCountForType(WindowTreeChangeType::VISIBLE));
783 775
784 // Make sure all the properties took. 776 // Make sure all the properties took.
785 // TODO(mfomitchev): Uncomment while crbug.com/crbug.com/672150 is fixed 777 EXPECT_TRUE(IsWindowHostVisible(top_level));
786 // EXPECT_TRUE(IsWindowHostVisible(top_level));
787 EXPECT_TRUE(top_level->TargetVisibility()); 778 EXPECT_TRUE(top_level->TargetVisibility());
779 // TODO: check display_id.
788 EXPECT_EQ(display_id, window_tree_host.display_id()); 780 EXPECT_EQ(display_id, window_tree_host.display_id());
789 EXPECT_EQ(gfx::Rect(0, 0, 3, 4), top_level->bounds()); 781 EXPECT_EQ(gfx::Rect(0, 0, 3, 4), top_level->bounds());
790 EXPECT_EQ(gfx::Rect(1, 2, 3, 4), top_level->GetHost()->GetBoundsInPixels()); 782 EXPECT_EQ(gfx::Rect(1, 2, 3, 4), top_level->GetHost()->GetBoundsInPixels());
791 } 783 }
792 784
793 TEST_F(WindowTreeClientClientTest, NewWindowGetsAllChangesInFlight) { 785 TEST_F(WindowTreeClientClientTest, NewWindowGetsAllChangesInFlight) {
794 RegisterTestProperties(GetPropertyConverter()); 786 RegisterTestProperties(GetPropertyConverter());
795 787
796 WindowTreeHostMus window_tree_host(window_tree_client_impl()); 788 WindowTreeHostMus window_tree_host(window_tree_client_impl());
797 Window* top_level = window_tree_host.window(); 789 Window* top_level = window_tree_host.window();
790
798 EXPECT_FALSE(top_level->TargetVisibility()); 791 EXPECT_FALSE(top_level->TargetVisibility());
799 792
800 window_tree_host.InitHost();
801
802 // Make visibility go from false->true->false. Don't ack immediately. 793 // Make visibility go from false->true->false. Don't ack immediately.
803 top_level->Show(); 794 top_level->Show();
804 top_level->Hide(); 795 top_level->Hide();
805 796
806 // Change bounds to 5, 6, 7, 8. 797 // Change bounds to 5, 6, 7, 8.
807 window_tree_host.SetBoundsInPixels(gfx::Rect(5, 6, 7, 8)); 798 window_tree_host.SetBoundsInPixels(gfx::Rect(5, 6, 7, 8));
808 EXPECT_EQ(gfx::Rect(0, 0, 7, 8), window_tree_host.window()->bounds()); 799 EXPECT_EQ(gfx::Rect(0, 0, 7, 8), window_tree_host.window()->bounds());
809 800
810 const uint8_t explicitly_set_test_property1_value = 2; 801 const uint8_t explicitly_set_test_property1_value = 2;
811 top_level->SetProperty(kTestPropertyKey1, 802 top_level->SetProperty(kTestPropertyKey1,
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 window_tree()->AckAllChangesOfType(WindowTreeChangeType::REORDER, true); 1017 window_tree()->AckAllChangesOfType(WindowTreeChangeType::REORDER, true);
1027 EXPECT_EQ(0u, window_tree()->number_of_changes()); 1018 EXPECT_EQ(0u, window_tree()->number_of_changes());
1028 } 1019 }
1029 1020
1030 TEST_F(WindowTreeClientClientTest, 1021 TEST_F(WindowTreeClientClientTest,
1031 TopLevelWindowDestroyedBeforeCreateComplete) { 1022 TopLevelWindowDestroyedBeforeCreateComplete) {
1032 const size_t initial_root_count = 1023 const size_t initial_root_count =
1033 window_tree_client_impl()->GetRoots().size(); 1024 window_tree_client_impl()->GetRoots().size();
1034 std::unique_ptr<WindowTreeHostMus> window_tree_host = 1025 std::unique_ptr<WindowTreeHostMus> window_tree_host =
1035 base::MakeUnique<WindowTreeHostMus>(window_tree_client_impl()); 1026 base::MakeUnique<WindowTreeHostMus>(window_tree_client_impl());
1036 window_tree_host->InitHost();
1037 EXPECT_EQ(initial_root_count + 1, 1027 EXPECT_EQ(initial_root_count + 1,
1038 window_tree_client_impl()->GetRoots().size()); 1028 window_tree_client_impl()->GetRoots().size());
1039 1029
1040 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New(); 1030 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New();
1041 data->window_id = server_id(window_tree_host->window()); 1031 data->window_id = server_id(window_tree_host->window());
1042 1032
1043 // Destroy the window before the server has a chance to ack the window 1033 // Destroy the window before the server has a chance to ack the window
1044 // creation. 1034 // creation.
1045 window_tree_host.reset(); 1035 window_tree_host.reset();
1046 EXPECT_EQ(initial_root_count, window_tree_client_impl()->GetRoots().size()); 1036 EXPECT_EQ(initial_root_count, window_tree_client_impl()->GetRoots().size());
(...skipping 16 matching lines...) Expand all
1063 properties[kTestPropertyServerKey1] = 1053 properties[kTestPropertyServerKey1] =
1064 ConvertToPropertyTransportValue(property_value); 1054 ConvertToPropertyTransportValue(property_value);
1065 const char kUnknownPropertyKey[] = "unknown-property"; 1055 const char kUnknownPropertyKey[] = "unknown-property";
1066 using UnknownPropertyType = int32_t; 1056 using UnknownPropertyType = int32_t;
1067 const UnknownPropertyType kUnknownPropertyValue = 101; 1057 const UnknownPropertyType kUnknownPropertyValue = 101;
1068 properties[kUnknownPropertyKey] = 1058 properties[kUnknownPropertyKey] =
1069 mojo::ConvertTo<std::vector<uint8_t>>(kUnknownPropertyValue); 1059 mojo::ConvertTo<std::vector<uint8_t>>(kUnknownPropertyValue);
1070 std::unique_ptr<WindowTreeHostMus> window_tree_host = 1060 std::unique_ptr<WindowTreeHostMus> window_tree_host =
1071 base::MakeUnique<WindowTreeHostMus>(window_tree_client_impl(), 1061 base::MakeUnique<WindowTreeHostMus>(window_tree_client_impl(),
1072 &properties); 1062 &properties);
1073 window_tree_host->InitHost();
1074 // Verify the property made it to the window. 1063 // Verify the property made it to the window.
1075 EXPECT_EQ(property_value, 1064 EXPECT_EQ(property_value,
1076 window_tree_host->window()->GetProperty(kTestPropertyKey1)); 1065 window_tree_host->window()->GetProperty(kTestPropertyKey1));
1077 1066
1078 // Get the id of the in flight change for creating the new top level window. 1067 // Get the id of the in flight change for creating the new top level window.
1079 uint32_t change_id; 1068 uint32_t change_id;
1080 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( 1069 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType(
1081 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id)); 1070 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id));
1082 1071
1083 // Verify the properties were sent to the server. 1072 // Verify the properties were sent to the server.
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
1390 .CallWmNewDisplayAdded(display, std::move(root_data), parent_drawn); 1379 .CallWmNewDisplayAdded(display, std::move(root_data), parent_drawn);
1391 EXPECT_EQ(display.bounds(), window_tree_host->GetBoundsInPixels()); 1380 EXPECT_EQ(display.bounds(), window_tree_host->GetBoundsInPixels());
1392 // The root window of the WindowTreeHost always has an origin of 0,0. 1381 // The root window of the WindowTreeHost always has an origin of 0,0.
1393 EXPECT_EQ(gfx::Rect(display.bounds().size()), 1382 EXPECT_EQ(gfx::Rect(display.bounds().size()),
1394 window_tree_host->window()->bounds()); 1383 window_tree_host->window()->bounds());
1395 EXPECT_TRUE(window_tree_host->window()->IsVisible()); 1384 EXPECT_TRUE(window_tree_host->window()->IsVisible());
1396 EXPECT_EQ(display.id(), window_tree_host->display_id()); 1385 EXPECT_EQ(display.id(), window_tree_host->display_id());
1397 } 1386 }
1398 1387
1399 } // namespace aura 1388 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/mus/window_tree_client.cc ('k') | ui/aura/window_tree_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698