| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/browser/ui/test/test_browser_dialog.h" | 5 #include "chrome/browser/ui/test/test_browser_dialog.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/test/gtest_util.h" | 9 #include "base/test/gtest_util.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 // Cocoa dialog will be created, which TestBrowserDialog doesn't support. | 81 // Cocoa dialog will be created, which TestBrowserDialog doesn't support. |
| 82 // Force SecondaryUiMaterial() on Mac to get coverage on the bots. Leave it | 82 // Force SecondaryUiMaterial() on Mac to get coverage on the bots. Leave it |
| 83 // optional elsewhere so that the non-MD dialog can be invoked to compare. | 83 // optional elsewhere so that the non-MD dialog can be invoked to compare. |
| 84 ui::test::MaterialDesignControllerTestAPI md_test_api( | 84 ui::test::MaterialDesignControllerTestAPI md_test_api( |
| 85 ui::MaterialDesignController::GetMode()); | 85 ui::MaterialDesignController::GetMode()); |
| 86 md_test_api.SetSecondaryUiMaterial(true); | 86 md_test_api.SetSecondaryUiMaterial(true); |
| 87 #endif | 87 #endif |
| 88 | 88 |
| 89 gfx::NativeView parent = platform_util::GetViewForWindow(DialogParent()); | 89 gfx::NativeView parent = platform_util::GetViewForWindow(DialogParent()); |
| 90 views::Widget::Widgets widgets_before; | 90 views::Widget::Widgets widgets_before; |
| 91 views::Widget::GetAllOwnedWidgets(parent, &widgets_before); | 91 views::Widget::GetAllChildWidgets(parent, &widgets_before); |
| 92 | 92 |
| 93 ShowDialog(NameFromTestCase()); | 93 ShowDialog(NameFromTestCase()); |
| 94 views::Widget::Widgets widgets_after; | 94 views::Widget::Widgets widgets_after; |
| 95 views::Widget::GetAllOwnedWidgets(parent, &widgets_after); | 95 views::Widget::GetAllChildWidgets(parent, &widgets_after); |
| 96 | 96 |
| 97 auto added = base::STLSetDifference<std::vector<views::Widget*>>( | 97 auto added = base::STLSetDifference<std::vector<views::Widget*>>( |
| 98 widgets_after, widgets_before); | 98 widgets_after, widgets_before); |
| 99 | 99 |
| 100 // This can fail if no dialog was shown, if the dialog shown wasn't a toolkit- | 100 // This can fail if no dialog was shown, if the dialog shown wasn't a toolkit- |
| 101 // views dialog, or if more than one child dialog was shown. | 101 // views dialog, or if more than one child dialog was shown. |
| 102 ASSERT_EQ(1u, added.size()); | 102 ASSERT_EQ(1u, added.size()); |
| 103 | 103 |
| 104 const DialogAction action = base::CommandLine::ForCurrentProcess()->HasSwitch( | 104 const DialogAction action = base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 105 internal::kInteractiveSwitch) | 105 internal::kInteractiveSwitch) |
| 106 ? DialogAction::INTERACTIVE | 106 ? DialogAction::INTERACTIVE |
| 107 : DialogAction::CLOSE_NOW; | 107 : DialogAction::CLOSE_NOW; |
| 108 | 108 |
| 109 WidgetCloser closer(added[0], action); | 109 WidgetCloser closer(added[0], action); |
| 110 ::test::RunTestInteractively(); | 110 ::test::RunTestInteractively(); |
| 111 } | 111 } |
| OLD | NEW |