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

Unified Diff: chrome/browser/ui/views/payments/view_stack_unittest.cc

Issue 2817533006: [Web Payments] Add PopMany and Size functions to ViewStack (Closed)
Patch Set: Remove unused Observer that caused use-after-free in tests. Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/payments/view_stack.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/payments/view_stack_unittest.cc
diff --git a/chrome/browser/ui/views/payments/view_stack_unittest.cc b/chrome/browser/ui/views/payments/view_stack_unittest.cc
index 81b678c26a308dbd8f8382df89c42514367be179..03997220fcca9bd673b9b338d4a2c01259fdfe6f 100644
--- a/chrome/browser/ui/views/payments/view_stack_unittest.cc
+++ b/chrome/browser/ui/views/payments/view_stack_unittest.cc
@@ -64,6 +64,37 @@ class ViewStackTest : public views::ViewsTestBase {
EXPECT_EQ(target, view->bounds());
}
+ // Pushes a view on the stack, waits for its animation to be over, then
+ // returns a pointer to the pushed view.
+ views::View* PushViewOnStackAndWait() {
+ std::unique_ptr<TestStackView> view = base::MakeUnique<TestStackView>();
+ views::View* view_ptr = view.get();
+
+ view_stack_->Push(std::move(view), true);
+ EXPECT_TRUE(view_stack_->slide_in_animator_->IsAnimating());
+ view_stack_->slide_in_animator_->SetAnimationDelegate(
+ view_ptr, std::unique_ptr<gfx::AnimationDelegate>(
+ new gfx::TestAnimationDelegate()));
+
+ base::RunLoop().Run();
+ EXPECT_FALSE(view_stack_->slide_in_animator_->IsAnimating());
+ return view_ptr;
+ }
+
+ // Pops |n| views from the stack, then waits for |top_view_ptr|'s animation to
+ // be over.
+ void PopManyAndWait(int n, views::View* top_view_ptr) {
+ view_stack_->PopMany(n);
+
+ EXPECT_TRUE(view_stack_->slide_out_animator_->IsAnimating());
+ view_stack_->slide_out_animator_->SetAnimationDelegate(
+ top_view_ptr, std::unique_ptr<gfx::AnimationDelegate>(
+ new gfx::TestAnimationDelegate()));
+
+ base::RunLoop().Run();
+ EXPECT_FALSE(view_stack_->slide_out_animator_->IsAnimating());
+ }
+
std::unique_ptr<ViewStack> view_stack_;
DISALLOW_COPY_AND_ASSIGN(ViewStackTest);
@@ -173,3 +204,23 @@ TEST_F(ViewStackTest, TestLayoutUpdatesAnimations) {
ASSERT_TRUE(observer.view_deleted());
}
+
+TEST_F(ViewStackTest, TestPopMany) {
+ views::View* top = PushViewOnStackAndWait();
+ EXPECT_EQ(2U, view_stack_->size());
+
+ PopManyAndWait(1, top);
+ EXPECT_EQ(1U, view_stack_->size());
+
+ top = PushViewOnStackAndWait();
+ top = PushViewOnStackAndWait();
+ top = PushViewOnStackAndWait();
+ EXPECT_EQ(4U, view_stack_->size());
+
+ PopManyAndWait(3, top);
+ EXPECT_EQ(1U, view_stack_->size());
+
+ top = PushViewOnStackAndWait();
+ top = PushViewOnStackAndWait();
+ EXPECT_EQ(3U, view_stack_->size());
+}
« no previous file with comments | « chrome/browser/ui/views/payments/view_stack.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698