@@ -21,6 +21,7 @@ public class HardwareConfigStateTest {
21
21
public void
22
22
setHardwareConfigIfAllowed_withAllowedState_setsInPreferredConfigAndMutable_returnsFalse () {
23
23
HardwareConfigState state = new HardwareConfigState ();
24
+ state .unblockHardwareBitmaps ();
24
25
BitmapFactory .Options options = new BitmapFactory .Options ();
25
26
boolean result =
26
27
state .setHardwareConfigIfAllowed (
@@ -39,6 +40,7 @@ public class HardwareConfigStateTest {
39
40
@ Test
40
41
public void setHardwareConfigIfAllowed_withSmallerThanMinWidth_returnsFalse_doesNotSetValues () {
41
42
HardwareConfigState state = new HardwareConfigState ();
43
+ state .unblockHardwareBitmaps ();
42
44
BitmapFactory .Options options = new BitmapFactory .Options ();
43
45
options .inPreferredConfig = null ;
44
46
options .inMutable = true ;
@@ -60,6 +62,7 @@ public void setHardwareConfigIfAllowed_withSmallerThanMinWidth_returnsFalse_does
60
62
@ Test
61
63
public void setHardwareConfigIfAllowed_withSmallerThanMinHeight_returnsFalse_doesNotSetValues () {
62
64
HardwareConfigState state = new HardwareConfigState ();
65
+ state .unblockHardwareBitmaps ();
63
66
BitmapFactory .Options options = new BitmapFactory .Options ();
64
67
options .inPreferredConfig = null ;
65
68
options .inMutable = true ;
@@ -82,6 +85,7 @@ public void setHardwareConfigIfAllowed_withSmallerThanMinHeight_returnsFalse_doe
82
85
public void
83
86
setHardwareConfigIfAllowed_withHardwareConfigDisallowed_returnsFalse_doesNotSetValues () {
84
87
HardwareConfigState state = new HardwareConfigState ();
88
+ state .unblockHardwareBitmaps ();
85
89
BitmapFactory .Options options = new BitmapFactory .Options ();
86
90
options .inPreferredConfig = null ;
87
91
options .inMutable = true ;
@@ -104,6 +108,7 @@ public void setHardwareConfigIfAllowed_withSmallerThanMinHeight_returnsFalse_doe
104
108
public void
105
109
setHardwareConfigIfAllowed_withExifOrientationRequired_returnsFalse_doesNotSetValues () {
106
110
HardwareConfigState state = new HardwareConfigState ();
111
+ state .unblockHardwareBitmaps ();
107
112
BitmapFactory .Options options = new BitmapFactory .Options ();
108
113
options .inPreferredConfig = null ;
109
114
options .inMutable = true ;
@@ -125,6 +130,29 @@ public void setHardwareConfigIfAllowed_withSmallerThanMinHeight_returnsFalse_doe
125
130
@ Test
126
131
public void setHardwareConfigIfAllowed_withOsLessThanO_returnsFalse_doesNotSetValues () {
127
132
HardwareConfigState state = new HardwareConfigState ();
133
+ state .unblockHardwareBitmaps ();
134
+ BitmapFactory .Options options = new BitmapFactory .Options ();
135
+ options .inPreferredConfig = null ;
136
+ options .inMutable = true ;
137
+
138
+ boolean result =
139
+ state .setHardwareConfigIfAllowed (
140
+ /*targetWidth=*/ HardwareConfigState .MIN_HARDWARE_DIMENSION_O ,
141
+ /*targetHeight=*/ HardwareConfigState .MIN_HARDWARE_DIMENSION_O ,
142
+ options ,
143
+ /*isHardwareConfigAllowed=*/ true ,
144
+ /*isExifOrientationRequired=*/ false );
145
+
146
+ assertThat (result ).isFalse ();
147
+ assertThat (options .inMutable ).isTrue ();
148
+ assertThat (options .inPreferredConfig ).isNull ();
149
+ }
150
+
151
+ @ Config (sdk = Build .VERSION_CODES .P )
152
+ @ Test
153
+ public void
154
+ setHardwareConfigIfAllowed_withOsLessThanQ_beforeUnblockingHardwareBitmaps_returnsFalseAndDoesNotSetValues () {
155
+ HardwareConfigState state = new HardwareConfigState ();
128
156
BitmapFactory .Options options = new BitmapFactory .Options ();
129
157
options .inPreferredConfig = null ;
130
158
options .inMutable = true ;
@@ -152,6 +180,7 @@ public void setHardwareConfigIfAllowed_withOsLessThanO_returnsFalse_doesNotSetVa
152
180
}) {
153
181
ShadowBuild .setModel (model );
154
182
HardwareConfigState state = new HardwareConfigState ();
183
+ state .unblockHardwareBitmaps ();
155
184
BitmapFactory .Options options = new BitmapFactory .Options ();
156
185
options .inPreferredConfig = null ;
157
186
options .inMutable = true ;
@@ -179,6 +208,7 @@ public void setHardwareConfigIfAllowed_withDisallowedSamsungDevices_OMR1_returns
179
208
}) {
180
209
ShadowBuild .setModel (model );
181
210
HardwareConfigState state = new HardwareConfigState ();
211
+ state .unblockHardwareBitmaps ();
182
212
BitmapFactory .Options options = new BitmapFactory .Options ();
183
213
options .inPreferredConfig = null ;
184
214
options .inMutable = true ;
@@ -206,6 +236,7 @@ public void setHardwareConfigIfAllowed_withShortEmptyOrNullModelNames_returnsTru
206
236
new String [] {null , "." , "-" , "" , "S" , "SM" , "SM-" , "SM-G" , "SM-G9." , "SM-G93" }) {
207
237
ShadowBuild .setModel (model );
208
238
HardwareConfigState state = new HardwareConfigState ();
239
+ state .unblockHardwareBitmaps ();
209
240
BitmapFactory .Options options = new BitmapFactory .Options ();
210
241
options .inPreferredConfig = null ;
211
242
options .inMutable = true ;
0 commit comments