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

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

Issue 2567293004: Makes WindowTreeHost::InitHost() not Show the window (Closed)
Patch Set: WTF::Show shows window 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
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 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 ASSERT_TRUE(window_tree()->AckSingleChangeOfType( 708 ASSERT_TRUE(window_tree()->AckSingleChangeOfType(
709 WindowTreeChangeType::VISIBLE, true)); 709 WindowTreeChangeType::VISIBLE, true));
710 } 710 }
711 711
712 TEST_F(WindowTreeClientClientTest, NewTopLevelWindow) { 712 TEST_F(WindowTreeClientClientTest, NewTopLevelWindow) {
713 const size_t initial_root_count = 713 const size_t initial_root_count =
714 window_tree_client_impl()->GetRoots().size(); 714 window_tree_client_impl()->GetRoots().size();
715 std::unique_ptr<WindowTreeHostMus> window_tree_host = 715 std::unique_ptr<WindowTreeHostMus> window_tree_host =
716 base::MakeUnique<WindowTreeHostMus>(window_tree_client_impl()); 716 base::MakeUnique<WindowTreeHostMus>(window_tree_client_impl());
717 window_tree_host->InitHost(); 717 window_tree_host->InitHost();
718 EXPECT_FALSE(window_tree_host->window()->TargetVisibility());
718 aura::Window* top_level = window_tree_host->window(); 719 aura::Window* top_level = window_tree_host->window();
719 // TODO: need to check WindowTreeHost visibility.
720 // EXPECT_TRUE(WindowPrivate(root2).parent_drawn());
721 EXPECT_NE(server_id(top_level), server_id(root_window())); 720 EXPECT_NE(server_id(top_level), server_id(root_window()));
722 EXPECT_EQ(initial_root_count + 1, 721 EXPECT_EQ(initial_root_count + 1,
723 window_tree_client_impl()->GetRoots().size()); 722 window_tree_client_impl()->GetRoots().size());
724 EXPECT_TRUE(window_tree_client_impl()->GetRoots().count(top_level) > 0u); 723 EXPECT_TRUE(window_tree_client_impl()->GetRoots().count(top_level) > 0u);
725 724
726 // Ack the request to the windowtree to create the new window. 725 // Ack the request to the windowtree to create the new window.
727 uint32_t change_id; 726 uint32_t change_id;
728 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( 727 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType(
729 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id)); 728 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id));
730 EXPECT_EQ(window_tree()->window_id(), server_id(top_level)); 729 EXPECT_EQ(window_tree()->window_id(), server_id(top_level));
731 730
732 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New(); 731 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New();
733 data->window_id = server_id(top_level); 732 data->window_id = server_id(top_level);
734 const int64_t display_id = 1; 733 const int64_t display_id = 1;
735 window_tree_client()->OnTopLevelCreated(change_id, std::move(data), 734 window_tree_client()->OnTopLevelCreated(change_id, std::move(data),
736 display_id, false); 735 display_id, false);
737 736
738 // TODO: need to check WindowTreeHost visibility. 737 EXPECT_FALSE(window_tree_host->window()->TargetVisibility());
739 // EXPECT_FALSE(WindowPrivate(root2).parent_drawn());
740 738
741 // Should not be able to add a top level as a child of another window. 739 // Should not be able to add a top level as a child of another window.
742 // TODO(sky): decide how to handle this. 740 // TODO(sky): decide how to handle this.
743 // root_window()->AddChild(top_level); 741 // root_window()->AddChild(top_level);
744 // ASSERT_EQ(nullptr, top_level->parent()); 742 // ASSERT_EQ(nullptr, top_level->parent());
745 743
746 // Destroy the first root, shouldn't initiate tear down. 744 // Destroy the first root, shouldn't initiate tear down.
747 window_tree_host.reset(); 745 window_tree_host.reset();
748 EXPECT_EQ(initial_root_count, window_tree_client_impl()->GetRoots().size()); 746 EXPECT_EQ(initial_root_count, window_tree_client_impl()->GetRoots().size());
749 } 747 }
750 748
751 TEST_F(WindowTreeClientClientTest, NewTopLevelWindowGetsPropertiesFromData) { 749 TEST_F(WindowTreeClientClientTest, NewTopLevelWindowGetsPropertiesFromData) {
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(); 760 window_tree_host.InitHost();
761 EXPECT_FALSE(window_tree_host.window()->TargetVisibility());
765 762
766 // Ack the request to the windowtree to create the new window. 763 // Ack the request to the windowtree to create the new window.
767 EXPECT_EQ(window_tree()->window_id(), server_id(top_level)); 764 EXPECT_EQ(window_tree()->window_id(), server_id(top_level));
768 765
769 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New(); 766 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New();
770 data->window_id = server_id(top_level); 767 data->window_id = server_id(top_level);
771 data->bounds.SetRect(1, 2, 3, 4); 768 data->bounds.SetRect(1, 2, 3, 4);
772 data->visible = true; 769 data->visible = true;
773 const int64_t display_id = 10; 770 const int64_t display_id = 10;
774 uint32_t change_id; 771 uint32_t change_id;
775 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( 772 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType(
776 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id)); 773 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id));
777 window_tree_client()->OnTopLevelCreated(change_id, std::move(data), 774 window_tree_client()->OnTopLevelCreated(change_id, std::move(data),
778 display_id, true); 775 display_id, true);
779 // TODO(mfomitchev): Uncomment while crbug.com/crbug.com/672150 is fixed 776 EXPECT_EQ(
780 // EXPECT_EQ( 777 0u, window_tree()->GetChangeCountForType(WindowTreeChangeType::VISIBLE));
781 // 0u,
782 // window_tree()->GetChangeCountForType(WindowTreeChangeType::VISIBLE));
783 778
784 // Make sure all the properties took. 779 // Make sure all the properties took.
785 // TODO(mfomitchev): Uncomment while crbug.com/crbug.com/672150 is fixed 780 EXPECT_TRUE(IsWindowHostVisible(top_level));
786 // EXPECT_TRUE(IsWindowHostVisible(top_level));
787 EXPECT_TRUE(top_level->TargetVisibility()); 781 EXPECT_TRUE(top_level->TargetVisibility());
788 EXPECT_EQ(display_id, window_tree_host.display_id()); 782 EXPECT_EQ(display_id, window_tree_host.display_id());
789 EXPECT_EQ(gfx::Rect(0, 0, 3, 4), top_level->bounds()); 783 EXPECT_EQ(gfx::Rect(0, 0, 3, 4), top_level->bounds());
790 EXPECT_EQ(gfx::Rect(1, 2, 3, 4), top_level->GetHost()->GetBoundsInPixels()); 784 EXPECT_EQ(gfx::Rect(1, 2, 3, 4), top_level->GetHost()->GetBoundsInPixels());
791 } 785 }
792 786
793 TEST_F(WindowTreeClientClientTest, NewWindowGetsAllChangesInFlight) { 787 TEST_F(WindowTreeClientClientTest, NewWindowGetsAllChangesInFlight) {
794 RegisterTestProperties(GetPropertyConverter()); 788 RegisterTestProperties(GetPropertyConverter());
795 789
796 WindowTreeHostMus window_tree_host(window_tree_client_impl()); 790 WindowTreeHostMus window_tree_host(window_tree_client_impl());
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 ConvertToPropertyTransportValue(property_value); 1058 ConvertToPropertyTransportValue(property_value);
1065 const char kUnknownPropertyKey[] = "unknown-property"; 1059 const char kUnknownPropertyKey[] = "unknown-property";
1066 using UnknownPropertyType = int32_t; 1060 using UnknownPropertyType = int32_t;
1067 const UnknownPropertyType kUnknownPropertyValue = 101; 1061 const UnknownPropertyType kUnknownPropertyValue = 101;
1068 properties[kUnknownPropertyKey] = 1062 properties[kUnknownPropertyKey] =
1069 mojo::ConvertTo<std::vector<uint8_t>>(kUnknownPropertyValue); 1063 mojo::ConvertTo<std::vector<uint8_t>>(kUnknownPropertyValue);
1070 std::unique_ptr<WindowTreeHostMus> window_tree_host = 1064 std::unique_ptr<WindowTreeHostMus> window_tree_host =
1071 base::MakeUnique<WindowTreeHostMus>(window_tree_client_impl(), 1065 base::MakeUnique<WindowTreeHostMus>(window_tree_client_impl(),
1072 &properties); 1066 &properties);
1073 window_tree_host->InitHost(); 1067 window_tree_host->InitHost();
1068 window_tree_host->window()->Show();
1074 // Verify the property made it to the window. 1069 // Verify the property made it to the window.
1075 EXPECT_EQ(property_value, 1070 EXPECT_EQ(property_value,
1076 window_tree_host->window()->GetProperty(kTestPropertyKey1)); 1071 window_tree_host->window()->GetProperty(kTestPropertyKey1));
1077 1072
1078 // Get the id of the in flight change for creating the new top level window. 1073 // Get the id of the in flight change for creating the new top level window.
1079 uint32_t change_id; 1074 uint32_t change_id;
1080 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( 1075 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType(
1081 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id)); 1076 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id));
1082 1077
1083 // Verify the properties were sent to the server. 1078 // 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); 1385 .CallWmNewDisplayAdded(display, std::move(root_data), parent_drawn);
1391 EXPECT_EQ(display.bounds(), window_tree_host->GetBoundsInPixels()); 1386 EXPECT_EQ(display.bounds(), window_tree_host->GetBoundsInPixels());
1392 // The root window of the WindowTreeHost always has an origin of 0,0. 1387 // The root window of the WindowTreeHost always has an origin of 0,0.
1393 EXPECT_EQ(gfx::Rect(display.bounds().size()), 1388 EXPECT_EQ(gfx::Rect(display.bounds().size()),
1394 window_tree_host->window()->bounds()); 1389 window_tree_host->window()->bounds());
1395 EXPECT_TRUE(window_tree_host->window()->IsVisible()); 1390 EXPECT_TRUE(window_tree_host->window()->IsVisible());
1396 EXPECT_EQ(display.id(), window_tree_host->display_id()); 1391 EXPECT_EQ(display.id(), window_tree_host->display_id());
1397 } 1392 }
1398 1393
1399 } // namespace aura 1394 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698