[go: nahoru, domu]

blob: 1175ae50f8f431f40ace01d91c5ddc8d173a3fea [file] [log] [blame]
Peter Kastinga4284ca2024-01-29 22:30:071// 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 Kasting134e9e5c2024-02-01 19:23:3910#include <memory>
11
Peter Kastinga4284ca2024-01-29 22:30:0712namespace views {
13
Peter Kasting134e9e5c2024-02-01 19:23:3914// `DeprecatedLayoutImmediately()` should be the only way to trigger layout
15// synchronously.
Peter Kastinga4284ca2024-01-29 22:30:0716struct SyncLayout : public View {
Peter Kasting134e9e5c2024-02-01 19:23:3917 SyncLayout() : child_(AddChildView(std::make_unique<View>())) {
18 child_->Layout(); // expected-error {{too few arguments to function call}}
19 }
20
Peter Kastinga4284ca2024-01-29 22:30:0721 void DoSomething() {
Peter Kasting134e9e5c2024-02-01 19:23:3922 Layout({}); // expected-error {{calling a private constructor}}
Peter Kastinga4284ca2024-01-29 22:30:0723 LayoutImmediately(); // expected-error {{'LayoutImmediately' is a private member}}
24 }
Peter Kasting134e9e5c2024-02-01 19:23:3925
26 private:
27 View* child_;
Peter Kastinga4284ca2024-01-29 22:30:0728};
29
Peter Kasting26addd25a2024-01-29 22:36:5030// `LayoutSuperclass<SuperT>(this)` should be the only way to trigger superclass
31// layout.
32struct SuperclassLayout : public View {
Peter Kasting134e9e5c2024-02-01 19:23:3933 void Layout(PassKey key) override {
34 View::Layout(key); // expected-error {{call to deleted constructor}}
Peter Kasting26addd25a2024-01-29 22:36:5035 LayoutSuperclass<SuperclassLayout>(this); // expected-error {{no matching member function}}
36 LayoutSuperclass<SyncLayout>(this); // expected-error {{no matching member function}}
37 }
38};
39
Peter Kastinga4284ca2024-01-29 22:30:0740} // namespace views