xref: /aosp_15_r20/external/google-fruit/tests/tested_features.md (revision a65addddcf69f38db5b288d787b6b7571a57bb8f)
1*a65addddSAndroid Build Coastguard Worker
2*a65addddSAndroid Build Coastguard Worker# Features tested in end-to-end tests
3*a65addddSAndroid Build Coastguard Worker
4*a65addddSAndroid Build Coastguard Worker#### INJECT macro
5*a65addddSAndroid Build Coastguard Worker* **TODO** Typical use-case
6*a65addddSAndroid Build Coastguard Worker* **TODO** With assisted params
7*a65addddSAndroid Build Coastguard Worker* **TODO** Check what happens with non-normalized types (all kinds)
8*a65addddSAndroid Build Coastguard Worker
9*a65addddSAndroid Build Coastguard Worker#### Binding to an instance
10*a65addddSAndroid Build Coastguard Worker* Using `bind(x)` or `bind<fruit::Annotated<A, T>>(x)`.
11*a65addddSAndroid Build Coastguard Worker* Check that calling bindInstance with a non-normalized type (e.g. const pointer, nonconst ptr, etc.) causes an error
12*a65addddSAndroid Build Coastguard Worker* Abstract class (ok)
13*a65addddSAndroid Build Coastguard Worker* Mismatched type arguments
14*a65addddSAndroid Build Coastguard Worker* Bind to subclass
15*a65addddSAndroid Build Coastguard Worker
16*a65addddSAndroid Build Coastguard Worker#### Interface bindings
17*a65addddSAndroid Build Coastguard Worker* Check that bind<T, T> causes an easy-to-understand error
18*a65addddSAndroid Build Coastguard Worker* bind<T, Annotated<A, T>>
19*a65addddSAndroid Build Coastguard Worker* Check that bind<X, Y>, bind<Y, Z> is allowed if Z derives from Y and Y derives from X
20*a65addddSAndroid Build Coastguard Worker* bind<X, Y> with X not a base class of Y
21*a65addddSAndroid Build Coastguard Worker* Check that the types passed to bind<> are normalized
22*a65addddSAndroid Build Coastguard Worker* Check that bind<I, C> also means bind<std::function<std::unique_ptr<I>(Args...)>, std::function<std::unique_ptr<C>(Args...)>> (with and without Args)
23*a65addddSAndroid Build Coastguard Worker
24*a65addddSAndroid Build Coastguard Worker##### Binding to a constructor
25*a65addddSAndroid Build Coastguard Worker* Explicitly, with a non-signature (not ok)
26*a65addddSAndroid Build Coastguard Worker* Implicitly, with a non-signature (not ok)
27*a65addddSAndroid Build Coastguard Worker* Implicitly, with a signature "returning" another type (not ok)
28*a65addddSAndroid Build Coastguard Worker* Implicitly, with a signature "returning" an annotated type (not ok)
29*a65addddSAndroid Build Coastguard Worker* Explicitly, with a signature that doesn't match any of the type's constructors
30*a65addddSAndroid Build Coastguard Worker* Implicitly, with a signature that doesn't match any of the type's constructors
31*a65addddSAndroid Build Coastguard Worker* **TODO** Using the Inject typedef
32*a65addddSAndroid Build Coastguard Worker* **TODO** Using the INJECT macro
33*a65addddSAndroid Build Coastguard Worker* **TODO** Also with no params
34*a65addddSAndroid Build Coastguard Worker* **TODO** Also for a templated class
35*a65addddSAndroid Build Coastguard Worker* **TODO** Also for a templated constructor (only explicitly or using Inject)
36*a65addddSAndroid Build Coastguard Worker* **TODO** With all kinds of non-normalized params (esp. with INJECT)
37*a65addddSAndroid Build Coastguard Worker* **TODO** With a constructor mistakenly taking an Assisted<X> or Annotated<A,X> parameter (instead of just using Assisted/Annotated in the Inject typedef)
38*a65addddSAndroid Build Coastguard Worker* For an abstract type (not ok), both implicit and explicit
39*a65addddSAndroid Build Coastguard Worker* **TODO** Check that a default-constructible type without an Inject typedef can't be auto-injected
40*a65addddSAndroid Build Coastguard Worker
41*a65addddSAndroid Build Coastguard Worker##### Binding to a provider
42*a65addddSAndroid Build Coastguard Worker* Returning a value
43*a65addddSAndroid Build Coastguard Worker* **TODO: ownership check** Returning a pointer (also check that Fruit takes ownership)
44*a65addddSAndroid Build Coastguard Worker* Check that lambdas with captures are forbidden
45*a65addddSAndroid Build Coastguard Worker* **TODO** Check that non-lambda functors/functions are forbidden
46*a65addddSAndroid Build Coastguard Worker* **TODO** Check that objects without operator() are forbidden
47*a65addddSAndroid Build Coastguard Worker* Passing a non-signature type
48*a65addddSAndroid Build Coastguard Worker* **TODO** Passing a signature type incompatible with the lambda's signature
49*a65addddSAndroid Build Coastguard Worker* **TODO** With a lambda mistakenly taking an Assisted<X> or Annotated<A,X> parameter (instead of just using Assisted/Annotated in the Inject typedef)
50*a65addddSAndroid Build Coastguard Worker* **TODO** For an abstract type (ok)
51*a65addddSAndroid Build Coastguard Worker* With a provider that returns nullptr (runtime error)
52*a65addddSAndroid Build Coastguard Worker
53*a65addddSAndroid Build Coastguard Worker#### Factory bindings
54*a65addddSAndroid Build Coastguard Worker* Explicit, using `registerFactory()`
55*a65addddSAndroid Build Coastguard Worker* Implicitly, with a signature "returning" an annotated type (not ok)
56*a65addddSAndroid Build Coastguard Worker* **TODO** Explicit, using `registerFactory()`, but passing a non-signature
57*a65addddSAndroid Build Coastguard Worker* Explicit, using `registerFactory()`, but with a lambda that has a different signature compared to the one given explicitly
58*a65addddSAndroid Build Coastguard Worker* Implicitly, with a signature that doesn't match any of the type's constructors
59*a65addddSAndroid Build Coastguard Worker* Check that lambdas with captures are forbidden in `registerFactory()`
60*a65addddSAndroid Build Coastguard Worker* **TODO** Check that non-lambda functors/functions are forbidden in `registerFactory()`
61*a65addddSAndroid Build Coastguard Worker* **TODO** Check that objects without operator() are forbidden in `registerFactory()`
62*a65addddSAndroid Build Coastguard Worker* Using the INJECT macro
63*a65addddSAndroid Build Coastguard Worker* With some assisted params and some injected params
64*a65addddSAndroid Build Coastguard Worker* **TODO** With no assisted params but some injected params
65*a65addddSAndroid Build Coastguard Worker* With some assisted params but no injected params
66*a65addddSAndroid Build Coastguard Worker* **TODO** With no assisted params and no injected params
67*a65addddSAndroid Build Coastguard Worker* **TODO** Using the factory in another class' constructor instead of getting it from the injector directly
68*a65addddSAndroid Build Coastguard Worker* **TODO** With a lambda mistakenly taking a Assisted<X>/Annotated<A,X> parameter (instead of just using Assisted/Annotated in the Inject typedef)
69*a65addddSAndroid Build Coastguard Worker* Explicit, for an abstract type (ok)
70*a65addddSAndroid Build Coastguard Worker* Implicit, for an abstract class (not ok)
71*a65addddSAndroid Build Coastguard Worker* Explicit, with a lambda returning a pointer (not supported)
72*a65addddSAndroid Build Coastguard Worker* Explicit, with a lambda returning a unique ptr (ok)
73*a65addddSAndroid Build Coastguard Worker* **TODO** With assisted params of all kinds of non-normalized types (especially in ASSISTED)
74*a65addddSAndroid Build Coastguard Worker* Implicitly, registering a `std::function<T(...)>` instead of a `std::function<std::unique_ptr<T>(...)>`
75*a65addddSAndroid Build Coastguard Worker* Explicitly, registering a `std::function<T(...)>` instead of a `std::function<std::unique_ptr<T>(...)>`
76*a65addddSAndroid Build Coastguard Worker* Implicitly, generating a binding for std::function<T()> when there is a binding for T
77*a65addddSAndroid Build Coastguard Worker* Implicitly, generating a binding for std::function<std::unique_ptr<T>()> when there is a binding for T
78*a65addddSAndroid Build Coastguard Worker* **TODO** Check that assisted params are passed in the right order when there are multiple
79*a65addddSAndroid Build Coastguard Worker* **TODO** Try calling the factory multiple times
80*a65addddSAndroid Build Coastguard Worker* Injecting a std::function<std::unique_ptr<T>(...)> with T not movable
81*a65addddSAndroid Build Coastguard Worker
82*a65addddSAndroid Build Coastguard Worker#### Annotated bindings
83*a65addddSAndroid Build Coastguard Worker* **TODO** Using `fruit::Annotated<>`
84*a65addddSAndroid Build Coastguard Worker* **TODO** Using the ANNOTATED macro (only in constructors using INJECT)
85*a65addddSAndroid Build Coastguard Worker* **TODO** Check possibly-misleading behavior of binding Annotated<A1, I> and Annotated<A2, I> to C (only 1 C instance is created and shared)
86*a65addddSAndroid Build Coastguard Worker* **TODO** With assisted params of all kinds of non-normalized types (especially in ANNOTATED)
87*a65addddSAndroid Build Coastguard Worker
88*a65addddSAndroid Build Coastguard Worker#### Multibindings
89*a65addddSAndroid Build Coastguard Worker* Interface multibindings
90*a65addddSAndroid Build Coastguard Worker* **TODO** Check that addMultibinding<I, I> causes an easy-to-understand error
91*a65addddSAndroid Build Coastguard Worker* Instance multibindings
92*a65addddSAndroid Build Coastguard Worker* **TODO** Check that calling addInstanceMultibinding with a non-normalized type (e.g. const pointer, nonconst ptr, etc.) causes an error
93*a65addddSAndroid Build Coastguard Worker* **TODO** `addInstanceMultibindings(x)`, `addInstanceMultibindings<T>(x)` and `addInstanceMultibindings<Annotated<A, T>>(x)`
94*a65addddSAndroid Build Coastguard Worker* **TODO** `addInstanceMultibindings()` with an empty vector
95*a65addddSAndroid Build Coastguard Worker* **TODO** Check that calling `addInstanceMultibindings()` with a non-normalized type causes an error
96*a65addddSAndroid Build Coastguard Worker* `addMultibindingProvider`:
97*a65addddSAndroid Build Coastguard Worker  * Returning a value
98*a65addddSAndroid Build Coastguard Worker  * **TODO: ownership check** Returning a pointer (also check that Fruit takes ownership)
99*a65addddSAndroid Build Coastguard Worker  * Check that lambdas with captures are forbidden
100*a65addddSAndroid Build Coastguard Worker  * **TODO** Check that non-lambda functors/functions are forbidden
101*a65addddSAndroid Build Coastguard Worker  * **TODO** Check that objects without operator() are forbidden
102*a65addddSAndroid Build Coastguard Worker  * Passing a non-signature type
103*a65addddSAndroid Build Coastguard Worker  * **TODO** Passing a signature type incompatible with the lambda's signature
104*a65addddSAndroid Build Coastguard Worker  * **TODO** With a lambda mistakenly taking an Assisted<X> or Annotated<A,X> parameter (instead of just using Assisted/Annotated in the Inject typedef)
105*a65addddSAndroid Build Coastguard Worker  * For an abstract type (not ok)
106*a65addddSAndroid Build Coastguard Worker  * With a provider that returns nullptr (runtime error)
107*a65addddSAndroid Build Coastguard Worker
108*a65addddSAndroid Build Coastguard Worker#### PartialComponent and Component
109*a65addddSAndroid Build Coastguard Worker* copy a Component
110*a65addddSAndroid Build Coastguard Worker* move a Component
111*a65addddSAndroid Build Coastguard Worker* move a PartialComponent
112*a65addddSAndroid Build Coastguard Worker* construction of a Component from another Component
113*a65addddSAndroid Build Coastguard Worker* construction of a Component from a PartialComponent
114*a65addddSAndroid Build Coastguard Worker* install() (old and new style)
115*a65addddSAndroid Build Coastguard Worker* Type already bound (various combinations, incl. binding+install)
116*a65addddSAndroid Build Coastguard Worker* No binding found for abstract class
117*a65addddSAndroid Build Coastguard Worker* Dependency loops
118*a65addddSAndroid Build Coastguard Worker* Run-time error for multiple inconsistent bindings in different components
119*a65addddSAndroid Build Coastguard Worker* Class-level static_asserts in Component
120*a65addddSAndroid Build Coastguard Worker  * Check that there are no repeated types
121*a65addddSAndroid Build Coastguard Worker  * Check that no type is both in Required<> and outside
122*a65addddSAndroid Build Coastguard Worker  * Check that all types are normalized
123*a65addddSAndroid Build Coastguard Worker  * Check that Required only appears once
124*a65addddSAndroid Build Coastguard Worker  * Check that Required only appears as first parameter (if at all)
125*a65addddSAndroid Build Coastguard Worker
126*a65addddSAndroid Build Coastguard Worker#### Normalized components
127*a65addddSAndroid Build Coastguard Worker* Constructing an injector from NC + C
128*a65addddSAndroid Build Coastguard Worker* **TODO** Constructing an injector from NC + C with empty NC or empty C
129*a65addddSAndroid Build Coastguard Worker* With requirements
130*a65addddSAndroid Build Coastguard Worker* Class-level static_asserts
131*a65addddSAndroid Build Coastguard Worker  * Check that there are no repeated types
132*a65addddSAndroid Build Coastguard Worker  * Check that no type is both in Required<> and outside
133*a65addddSAndroid Build Coastguard Worker  * **TODO** Check that all types are normalized
134*a65addddSAndroid Build Coastguard Worker  * Check that Required only appears once
135*a65addddSAndroid Build Coastguard Worker  * Check that Required only appears as first parameter (if at all)
136*a65addddSAndroid Build Coastguard Worker
137*a65addddSAndroid Build Coastguard Worker#### Components with requirements
138*a65addddSAndroid Build Coastguard Worker* Usual case (where the required type is only forward-declared, with no definition available)
139*a65addddSAndroid Build Coastguard Worker* Usual case (where the required type is defined but it's an abstract class)
140*a65addddSAndroid Build Coastguard Worker* **TODO** Check that requirements aren't allowed in injectors
141*a65addddSAndroid Build Coastguard Worker* Check that multiple Required<...> params are not allowed
142*a65addddSAndroid Build Coastguard Worker* Check that the Required<...> param is only allowed if it's the 1st
143*a65addddSAndroid Build Coastguard Worker* **TODO** Check that an empty Required<...> param is allowed
144*a65addddSAndroid Build Coastguard Worker
145*a65addddSAndroid Build Coastguard Worker#### Injectors
146*a65addddSAndroid Build Coastguard Worker* **TODO** `std::move()`-ing an injector
147*a65addddSAndroid Build Coastguard Worker* Getting instances from an Injector:
148*a65addddSAndroid Build Coastguard Worker  * **TODO** Using `get<T>` (for all type variations)
149*a65addddSAndroid Build Coastguard Worker  * **TODO** Using `get()` or casting to try to get a value that the injector doesn't provide
150*a65addddSAndroid Build Coastguard Worker  * **TODO** Casting the injector to the desired type
151*a65addddSAndroid Build Coastguard Worker* Getting multibindings from an Injector
152*a65addddSAndroid Build Coastguard Worker  * for a type that has no multibindings
153*a65addddSAndroid Build Coastguard Worker  * for a type that has 1 multibinding
154*a65addddSAndroid Build Coastguard Worker  * for a type that has >1 multibindings
155*a65addddSAndroid Build Coastguard Worker* **TODO** Eager injection
156*a65addddSAndroid Build Coastguard Worker* **TODO** Check that the component (in the constructor from C) has no requirements
157*a65addddSAndroid Build Coastguard Worker* **TODO** Check that the resulting component (in the constructor from C+NC) has no requirements
158*a65addddSAndroid Build Coastguard Worker* **TODO: partial** Empty injector (construct, get multibindings, eager injection, etc.)
159*a65addddSAndroid Build Coastguard Worker* **TODO** Injector with a single instance type bound and nothing else
160*a65addddSAndroid Build Coastguard Worker* **TODO** Injector with a single bindProvider and nothing else
161*a65addddSAndroid Build Coastguard Worker* **TODO** Injector with a single multibinding and nothing else
162*a65addddSAndroid Build Coastguard Worker* **TODO** Injector with a single factory and nothing else
163*a65addddSAndroid Build Coastguard Worker* Injector<T> where the C doesn't provide T
164*a65addddSAndroid Build Coastguard Worker* Injector<T> where the C+NC don't provide T
165*a65addddSAndroid Build Coastguard Worker* Class-level static_asserts
166*a65addddSAndroid Build Coastguard Worker  * Check that there are no repeated types
167*a65addddSAndroid Build Coastguard Worker  * Check that all types are normalized
168*a65addddSAndroid Build Coastguard Worker  * Check that there are no Required types
169*a65addddSAndroid Build Coastguard Worker
170*a65addddSAndroid Build Coastguard Worker#### Injecting Provider<>s
171*a65addddSAndroid Build Coastguard Worker* **TODO** In constructors
172*a65addddSAndroid Build Coastguard Worker* Getting a Provider<> from an injector using get<> or casting the injector)
173*a65addddSAndroid Build Coastguard Worker* **TODO** Getting a Provider<> from an injector by casting the injector
174*a65addddSAndroid Build Coastguard Worker* In a constructor and calling get() before the constructor completes
175*a65addddSAndroid Build Coastguard Worker* **TODO** casting a Provider to the desired value instead of calling `get()`
176*a65addddSAndroid Build Coastguard Worker* **TODO** Calling either `get<T>()` or `get()` on the Provider
177*a65addddSAndroid Build Coastguard Worker* **TODO** Check that a Provider's type argument is normalized and not annotated
178*a65addddSAndroid Build Coastguard Worker* Copying a Provider and using the copy
179*a65addddSAndroid Build Coastguard Worker* Using `get()` to try to get a value that the provider doesn't provide
180*a65addddSAndroid Build Coastguard Worker* Class-level static_asserts
181*a65addddSAndroid Build Coastguard Worker  * Check that the type is normalized
182*a65addddSAndroid Build Coastguard Worker  * Check that the type is not annotated
183