Peter Kasting | a4284ca | 2024-01-29 22:30:07 | [diff] [blame] | 1 | // Copyright 2024 The Chromium Authors |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | // This is a "No Compile Test" suite. |
| 6 | // http://dev.chromium.org/developers/testing/no-compile-tests |
| 7 | |
| 8 | #include "ui/views/view.h" |
| 9 | |
Peter Kasting | 134e9e5c | 2024-02-01 19:23:39 | [diff] [blame] | 10 | #include <memory> |
| 11 | |
Peter Kasting | a4284ca | 2024-01-29 22:30:07 | [diff] [blame] | 12 | namespace views { |
| 13 | |
Peter Kasting | 134e9e5c | 2024-02-01 19:23:39 | [diff] [blame] | 14 | // `DeprecatedLayoutImmediately()` should be the only way to trigger layout |
| 15 | // synchronously. |
Peter Kasting | a4284ca | 2024-01-29 22:30:07 | [diff] [blame] | 16 | struct SyncLayout : public View { |
Peter Kasting | 134e9e5c | 2024-02-01 19:23:39 | [diff] [blame] | 17 | SyncLayout() : child_(AddChildView(std::make_unique<View>())) { |
| 18 | child_->Layout(); // expected-error {{too few arguments to function call}} |
| 19 | } |
| 20 | |
Peter Kasting | a4284ca | 2024-01-29 22:30:07 | [diff] [blame] | 21 | void DoSomething() { |
Peter Kasting | 134e9e5c | 2024-02-01 19:23:39 | [diff] [blame] | 22 | Layout({}); // expected-error {{calling a private constructor}} |
Peter Kasting | a4284ca | 2024-01-29 22:30:07 | [diff] [blame] | 23 | LayoutImmediately(); // expected-error {{'LayoutImmediately' is a private member}} |
| 24 | } |
Peter Kasting | 134e9e5c | 2024-02-01 19:23:39 | [diff] [blame] | 25 | |
| 26 | private: |
| 27 | View* child_; |
Peter Kasting | a4284ca | 2024-01-29 22:30:07 | [diff] [blame] | 28 | }; |
| 29 | |
Peter Kasting | 26addd25a | 2024-01-29 22:36:50 | [diff] [blame] | 30 | // `LayoutSuperclass<SuperT>(this)` should be the only way to trigger superclass |
| 31 | // layout. |
| 32 | struct SuperclassLayout : public View { |
Peter Kasting | 134e9e5c | 2024-02-01 19:23:39 | [diff] [blame] | 33 | void Layout(PassKey key) override { |
| 34 | View::Layout(key); // expected-error {{call to deleted constructor}} |
Peter Kasting | 26addd25a | 2024-01-29 22:36:50 | [diff] [blame] | 35 | LayoutSuperclass<SuperclassLayout>(this); // expected-error {{no matching member function}} |
| 36 | LayoutSuperclass<SyncLayout>(this); // expected-error {{no matching member function}} |
| 37 | } |
| 38 | }; |
| 39 | |
Peter Kasting | a4284ca | 2024-01-29 22:30:07 | [diff] [blame] | 40 | } // namespace views |