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

Side by Side Diff: components/mus/public/cpp/tests/window_tree_client_impl_unittest.cc

Issue 1906623003: Convert //components/mus from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 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 "components/mus/public/cpp/lib/window_tree_client_impl.h" 5 #include "components/mus/public/cpp/lib/window_tree_client_impl.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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 } 135 }
136 136
137 void Reset() { 137 void Reset() {
138 received_event_ = false; 138 received_event_ = false;
139 ack_callback_ = base::Bind(&DoNothingWithEventResult); 139 ack_callback_ = base::Bind(&DoNothingWithEventResult);
140 } 140 }
141 bool received_event() const { return received_event_; } 141 bool received_event() const { return received_event_; }
142 142
143 private: 143 private:
144 // InputEventHandler: 144 // InputEventHandler:
145 void OnWindowInputEvent(Window* target, 145 void OnWindowInputEvent(
146 const ui::Event& event, 146 Window* target,
147 scoped_ptr<base::Callback<void(mojom::EventResult)>>* 147 const ui::Event& event,
148 ack_callback) override { 148 std::unique_ptr<base::Callback<void(mojom::EventResult)>>* ack_callback)
149 override {
149 EXPECT_FALSE(received_event_) 150 EXPECT_FALSE(received_event_)
150 << "Observer was not reset after receiving event."; 151 << "Observer was not reset after receiving event.";
151 received_event_ = true; 152 received_event_ = true;
152 if (should_manually_ack_) { 153 if (should_manually_ack_) {
153 ack_callback_ = *ack_callback->get(); 154 ack_callback_ = *ack_callback->get();
154 ack_callback->reset(); 155 ack_callback->reset();
155 } 156 }
156 } 157 }
157 158
158 bool received_event_; 159 bool received_event_;
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 } 454 }
454 455
455 TEST_F(WindowTreeClientImplTest, InputEventBasic) { 456 TEST_F(WindowTreeClientImplTest, InputEventBasic) {
456 WindowTreeSetup setup; 457 WindowTreeSetup setup;
457 Window* root = setup.GetFirstRoot(); 458 Window* root = setup.GetFirstRoot();
458 ASSERT_TRUE(root); 459 ASSERT_TRUE(root);
459 460
460 TestInputEventHandler event_handler; 461 TestInputEventHandler event_handler;
461 root->set_input_event_handler(&event_handler); 462 root->set_input_event_handler(&event_handler);
462 463
463 scoped_ptr<ui::Event> ui_event( 464 std::unique_ptr<ui::Event> ui_event(
464 new ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), 465 new ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(),
465 ui::EventTimeForNow(), ui::EF_NONE, 0)); 466 ui::EventTimeForNow(), ui::EF_NONE, 0));
466 setup.window_tree_client()->OnWindowInputEvent( 467 setup.window_tree_client()->OnWindowInputEvent(
467 1, server_id(root), mojom::Event::From(*ui_event.get())); 468 1, server_id(root), mojom::Event::From(*ui_event.get()));
468 EXPECT_TRUE(event_handler.received_event()); 469 EXPECT_TRUE(event_handler.received_event());
469 EXPECT_TRUE(setup.window_tree()->WasEventAcked(1)); 470 EXPECT_TRUE(setup.window_tree()->WasEventAcked(1));
470 event_handler.Reset(); 471 event_handler.Reset();
471 472
472 event_handler.set_should_manually_ack(); 473 event_handler.set_should_manually_ack();
473 setup.window_tree_client()->OnWindowInputEvent( 474 setup.window_tree_client()->OnWindowInputEvent(
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 EXPECT_EQ(2u, root2->shared_properties().size()); 763 EXPECT_EQ(2u, root2->shared_properties().size());
763 ASSERT_TRUE(root2->HasSharedProperty("yy")); 764 ASSERT_TRUE(root2->HasSharedProperty("yy"));
764 EXPECT_EQ("server_yy", root2->GetSharedProperty<std::string>("yy")); 765 EXPECT_EQ("server_yy", root2->GetSharedProperty<std::string>("yy"));
765 ASSERT_TRUE(root2->HasSharedProperty("xx")); 766 ASSERT_TRUE(root2->HasSharedProperty("xx"));
766 EXPECT_EQ("server_xx", root2->GetSharedProperty<std::string>("xx")); 767 EXPECT_EQ("server_xx", root2->GetSharedProperty<std::string>("xx"));
767 } 768 }
768 769
769 // Tests that if the client has multiple unowned windows, and one of them is a 770 // Tests that if the client has multiple unowned windows, and one of them is a
770 // transient child to another, the teardown can happen cleanly. 771 // transient child to another, the teardown can happen cleanly.
771 TEST_F(WindowTreeClientImplTest, MultipleUnOwnedWindowsDuringDestruction) { 772 TEST_F(WindowTreeClientImplTest, MultipleUnOwnedWindowsDuringDestruction) {
772 scoped_ptr<WindowTreeSetup> setup(new WindowTreeSetup()); 773 std::unique_ptr<WindowTreeSetup> setup(new WindowTreeSetup());
773 Window* root1 = setup->GetFirstRoot(); 774 Window* root1 = setup->GetFirstRoot();
774 ASSERT_TRUE(root1); 775 ASSERT_TRUE(root1);
775 Window* root2 = setup->window_tree_connection()->NewTopLevelWindow(nullptr); 776 Window* root2 = setup->window_tree_connection()->NewTopLevelWindow(nullptr);
776 ASSERT_TRUE(root2); 777 ASSERT_TRUE(root2);
777 root1->AddTransientWindow(root2); 778 root1->AddTransientWindow(root2);
778 779
779 WindowTracker tracker; 780 WindowTracker tracker;
780 tracker.Add(root1); 781 tracker.Add(root1);
781 tracker.Add(root2); 782 tracker.Add(root2);
782 setup.reset(); 783 setup.reset();
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 921
921 setup.window_tree_client()->OnChangeCompleted(change_id2, false); 922 setup.window_tree_client()->OnChangeCompleted(change_id2, false);
922 EXPECT_FALSE(child->HasCapture()); 923 EXPECT_FALSE(child->HasCapture());
923 EXPECT_TRUE(root->HasCapture()); 924 EXPECT_TRUE(root->HasCapture());
924 925
925 setup.window_tree_client()->OnLostCapture(server_id(root)); 926 setup.window_tree_client()->OnLostCapture(server_id(root));
926 EXPECT_FALSE(root->HasCapture()); 927 EXPECT_FALSE(root->HasCapture());
927 } 928 }
928 929
929 } // namespace mus 930 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/public/cpp/tests/window_server_test_base.cc ('k') | components/mus/public/cpp/tests/window_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698