forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathselect_file_dialog_mac_unittest.mm
546 lines (462 loc) · 20.1 KB
/
select_file_dialog_mac_unittest.mm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ui/shell_dialogs/select_file_dialog_mac.h"
#include "base/cxx17_backports.h"
#include "base/files/file_util.h"
#import "base/mac/foundation_util.h"
#include "base/mac/mac_util.h"
#include "base/memory/ref_counted.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/task_environment.h"
#include "components/remote_cocoa/app_shim/select_file_dialog_bridge.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/shell_dialogs/select_file_policy.h"
#define EXPECT_EQ_BOOL(a, b) \
EXPECT_EQ(static_cast<bool>(a), static_cast<bool>(b))
namespace {
const int kFileTypePopupTag = 1234;
// Returns a vector containing extension descriptions for a given popup.
std::vector<std::u16string> GetExtensionDescriptionList(NSPopUpButton* popup) {
std::vector<std::u16string> extension_descriptions;
for (NSString* description in [popup itemTitles])
extension_descriptions.push_back(base::SysNSStringToUTF16(description));
return extension_descriptions;
}
// Fake user event to select the item at the given |index| from the extension
// dropdown popup.
void SelectItemAtIndex(NSPopUpButton* popup, int index) {
[[popup menu] performActionForItemAtIndex:index];
}
// Returns the NSPopupButton associated with the given |panel|.
NSPopUpButton* GetPopup(NSSavePanel* panel) {
return [[panel accessoryView] viewWithTag:kFileTypePopupTag];
}
// Helper method to convert an array to a vector.
template <typename T, size_t N>
std::vector<T> GetVectorFromArray(const T (&data)[N]) {
return std::vector<T>(data, data + N);
}
} // namespace
namespace ui {
namespace test {
// Helper test base to initialize SelectFileDialogImpl.
class SelectFileDialogMacTest : public ::testing::Test,
public SelectFileDialog::Listener {
public:
SelectFileDialogMacTest()
: dialog_(new SelectFileDialogImpl(this, nullptr)) {}
SelectFileDialogMacTest(const SelectFileDialogMacTest&) = delete;
SelectFileDialogMacTest& operator=(const SelectFileDialogMacTest&) = delete;
// Overridden from SelectFileDialog::Listener.
void FileSelected(const base::FilePath& path,
int index,
void* params) override {}
protected:
base::test::TaskEnvironment task_environment_;
struct FileDialogArguments {
SelectFileDialog::Type type = SelectFileDialog::SELECT_SAVEAS_FILE;
std::u16string title;
base::FilePath default_path;
SelectFileDialog::FileTypeInfo* file_types = nullptr;
int file_type_index = 0;
base::FilePath::StringType default_extension;
gfx::NativeWindow owning_window = nullptr;
void* params = nullptr;
};
// Helper method to launch a dialog with the given |args|.
void SelectFileWithParams(FileDialogArguments args) {
dialog_->SelectFile(args.type, args.title, args.default_path,
args.file_types, args.file_type_index,
args.default_extension, args.owning_window,
args.params);
base::RunLoop().RunUntilIdle();
}
// Returns the number of panels currently active.
size_t GetActivePanelCount() const {
return dialog_->dialog_data_list_.size();
}
// Returns the most recently created NSSavePanel.
NSSavePanel* GetPanel() const {
DCHECK_GE(GetActivePanelCount(), 1lu);
return remote_cocoa::SelectFileDialogBridge::
GetLastCreatedNativePanelForTesting();
}
void ResetDialog() {
dialog_ = new SelectFileDialogImpl(this, nullptr);
base::RunLoop().RunUntilIdle();
}
private:
scoped_refptr<SelectFileDialogImpl> dialog_;
};
class SelectFileDialogMacOpenAndSaveTest
: public SelectFileDialogMacTest,
public ::testing::WithParamInterface<SelectFileDialog::Type> {};
INSTANTIATE_TEST_SUITE_P(All,
SelectFileDialogMacOpenAndSaveTest,
::testing::Values(SelectFileDialog::SELECT_SAVEAS_FILE,
SelectFileDialog::SELECT_OPEN_FILE));
// Verify that the extension popup has the correct description and changing the
// popup item changes the allowed file types.
TEST_F(SelectFileDialogMacTest, ExtensionPopup) {
const std::string extensions_arr[][2] = {{"html", "htm"}, {"jpeg", "jpg"}};
const std::u16string extension_descriptions_arr[] = {u"Webpage", u"Image"};
SelectFileDialog::FileTypeInfo file_type_info;
file_type_info.extensions.push_back(
GetVectorFromArray<std::string>(extensions_arr[0]));
file_type_info.extensions.push_back(
GetVectorFromArray<std::string>(extensions_arr[1]));
file_type_info.extension_description_overrides =
GetVectorFromArray<std::u16string>(extension_descriptions_arr);
file_type_info.include_all_files = false;
FileDialogArguments args;
args.file_types = &file_type_info;
SelectFileWithParams(args);
NSSavePanel* panel = GetPanel();
NSPopUpButton* popup = GetPopup(panel);
EXPECT_TRUE(popup);
// Check that the dropdown list created has the correct description.
const std::vector<std::u16string> extension_descriptions =
GetExtensionDescriptionList(popup);
EXPECT_EQ(file_type_info.extension_description_overrides,
extension_descriptions);
// Ensure other file types are not allowed.
EXPECT_FALSE([panel allowsOtherFileTypes]);
// Check that the first item was selected, since a file_type_index of 0 was
// passed and no default extension was provided.
EXPECT_EQ(0, [popup indexOfSelectedItem]);
EXPECT_TRUE([[panel allowedFileTypes] containsObject:@"htm"]);
EXPECT_TRUE([[panel allowedFileTypes] containsObject:@"html"]);
// Extensions should appear in order of input.
EXPECT_LT([[panel allowedFileTypes] indexOfObject:@"html"],
[[panel allowedFileTypes] indexOfObject:@"htm"]);
EXPECT_FALSE([[panel allowedFileTypes] containsObject:@"jpg"]);
// Select the second item.
SelectItemAtIndex(popup, 1);
EXPECT_EQ(1, [popup indexOfSelectedItem]);
EXPECT_TRUE([[panel allowedFileTypes] containsObject:@"jpg"]);
EXPECT_TRUE([[panel allowedFileTypes] containsObject:@"jpeg"]);
// Extensions should appear in order of input.
EXPECT_LT([[panel allowedFileTypes] indexOfObject:@"jpeg"],
[[panel allowedFileTypes] indexOfObject:@"jpg"]);
EXPECT_FALSE([[panel allowedFileTypes] containsObject:@"html"]);
}
// Verify file_type_info.include_all_files argument is respected.
TEST_P(SelectFileDialogMacOpenAndSaveTest, IncludeAllFiles) {
const std::string extensions_arr[][2] = {{"html", "htm"}, {"jpeg", "jpg"}};
const std::u16string extension_descriptions_arr[] = {u"Webpage", u"Image"};
SelectFileDialog::FileTypeInfo file_type_info;
file_type_info.extensions.push_back(
GetVectorFromArray<std::string>(extensions_arr[0]));
file_type_info.extensions.push_back(
GetVectorFromArray<std::string>(extensions_arr[1]));
file_type_info.extension_description_overrides =
GetVectorFromArray<std::u16string>(extension_descriptions_arr);
file_type_info.include_all_files = true;
FileDialogArguments args;
args.type = GetParam();
args.file_types = &file_type_info;
SelectFileWithParams(args);
NSSavePanel* panel = GetPanel();
NSPopUpButton* popup = GetPopup(panel);
EXPECT_TRUE(popup);
// Ensure other file types are allowed.
EXPECT_TRUE([panel allowsOtherFileTypes]);
// Check that the dropdown list created has the correct description.
const std::vector<std::u16string> extension_descriptions =
GetExtensionDescriptionList(popup);
// Save dialogs don't have "all files".
if (args.type == SelectFileDialog::SELECT_SAVEAS_FILE) {
ASSERT_EQ(2lu, extension_descriptions.size());
EXPECT_EQ(u"Webpage", extension_descriptions[0]);
EXPECT_EQ(u"Image", extension_descriptions[1]);
} else {
ASSERT_EQ(3lu, extension_descriptions.size());
EXPECT_EQ(u"Webpage", extension_descriptions[0]);
EXPECT_EQ(u"Image", extension_descriptions[1]);
EXPECT_EQ(u"All Files", extension_descriptions[2]);
// Note that no further testing on the popup can be done. Open dialogs are
// out-of-process starting in macOS 10.15, so once it's been run and closed,
// the accessory view controls no longer work.
}
}
// Verify that file_type_index and default_extension arguments cause the
// appropriate extension group to be initially selected.
TEST_F(SelectFileDialogMacTest, InitialSelection) {
const std::string extensions_arr[][2] = {{"html", "htm"}, {"jpeg", "jpg"}};
const std::u16string extension_descriptions_arr[] = {u"Webpage", u"Image"};
SelectFileDialog::FileTypeInfo file_type_info;
file_type_info.extensions.push_back(
GetVectorFromArray<std::string>(extensions_arr[0]));
file_type_info.extensions.push_back(
GetVectorFromArray<std::string>(extensions_arr[1]));
file_type_info.extension_description_overrides =
GetVectorFromArray<std::u16string>(extension_descriptions_arr);
FileDialogArguments args;
args.file_types = &file_type_info;
args.file_type_index = 2;
args.default_extension = "jpg";
SelectFileWithParams(args);
NSSavePanel* panel = GetPanel();
NSPopUpButton* popup = GetPopup(panel);
EXPECT_TRUE(popup);
// Verify that the file_type_index causes the second item to be initially
// selected.
EXPECT_EQ(1, [popup indexOfSelectedItem]);
EXPECT_TRUE([[panel allowedFileTypes] containsObject:@"jpg"]);
EXPECT_TRUE([[panel allowedFileTypes] containsObject:@"jpeg"]);
EXPECT_FALSE([[panel allowedFileTypes] containsObject:@"html"]);
ResetDialog();
args.file_type_index = 0;
args.default_extension = "pdf";
SelectFileWithParams(args);
panel = GetPanel();
popup = GetPopup(panel);
EXPECT_TRUE(popup);
// Verify that the first item was selected, since the default extension passed
// was not present in the extension list.
EXPECT_EQ(0, [popup indexOfSelectedItem]);
EXPECT_TRUE([[panel allowedFileTypes] containsObject:@"html"]);
EXPECT_TRUE([[panel allowedFileTypes] containsObject:@"htm"]);
EXPECT_FALSE([[panel allowedFileTypes] containsObject:@"pdf"]);
EXPECT_FALSE([[panel allowedFileTypes] containsObject:@"jpeg"]);
ResetDialog();
args.file_type_index = 0;
args.default_extension = "jpg";
SelectFileWithParams(args);
panel = GetPanel();
popup = GetPopup(panel);
EXPECT_TRUE(popup);
// Verify that the extension group corresponding to the default extension is
// initially selected.
EXPECT_EQ(1, [popup indexOfSelectedItem]);
// The allowed file types should just contain the default extension.
EXPECT_EQ(1lu, [[panel allowedFileTypes] count]);
EXPECT_TRUE([[panel allowedFileTypes] containsObject:@"jpg"]);
EXPECT_FALSE([[panel allowedFileTypes] containsObject:@"jpeg"]);
EXPECT_FALSE([[panel allowedFileTypes] containsObject:@"html"]);
}
// Verify that an appropriate extension description is shown even if an empty
// extension description is passed for a given extension group.
TEST_F(SelectFileDialogMacTest, EmptyDescription) {
const std::string extensions_arr[][1] = {{"pdf"}, {"jpg"}, {"qqq"}};
const std::u16string extension_descriptions_arr[] = {u"", u"Image", u""};
SelectFileDialog::FileTypeInfo file_type_info;
file_type_info.extensions.push_back(
GetVectorFromArray<std::string>(extensions_arr[0]));
file_type_info.extensions.push_back(
GetVectorFromArray<std::string>(extensions_arr[1]));
file_type_info.extensions.push_back(
GetVectorFromArray<std::string>(extensions_arr[2]));
file_type_info.extension_description_overrides =
GetVectorFromArray<std::u16string>(extension_descriptions_arr);
FileDialogArguments args;
args.file_types = &file_type_info;
SelectFileWithParams(args);
NSSavePanel* panel = GetPanel();
NSPopUpButton* popup = GetPopup(panel);
EXPECT_TRUE(popup);
// Check that the dropdown list created has the correct description.
const std::vector<std::u16string> extension_descriptions =
GetExtensionDescriptionList(popup);
EXPECT_EQ(3lu, extension_descriptions.size());
// Verify that the correct system description is produced for known file types
// like pdf if no extension description is provided by the client. Search the
// string for "PDF" as the system may display:
// - Portable Document Format (PDF)
// - PDF document
EXPECT_NE(std::u16string::npos, extension_descriptions[0].find(u"PDF"));
EXPECT_EQ(u"Image", extension_descriptions[1]);
// Verify the description for unknown file types if no extension description
// is provided by the client.
EXPECT_EQ(u"QQQ File (.qqq)", extension_descriptions[2]);
}
// Verify that passing an empty extension list in file_type_info causes no
// extension dropdown to display.
TEST_P(SelectFileDialogMacOpenAndSaveTest, EmptyExtension) {
SelectFileDialog::FileTypeInfo file_type_info;
FileDialogArguments args;
args.type = GetParam();
args.file_types = &file_type_info;
SelectFileWithParams(args);
NSSavePanel* panel = GetPanel();
EXPECT_FALSE([panel accessoryView]);
// Ensure other file types are allowed.
EXPECT_TRUE([panel allowsOtherFileTypes]);
}
// Verify that passing a null file_types value causes no extension dropdown to
// display.
TEST_F(SelectFileDialogMacTest, FileTypesNull) {
SelectFileWithParams({});
NSSavePanel* panel = GetPanel();
EXPECT_TRUE([panel allowsOtherFileTypes]);
EXPECT_FALSE([panel accessoryView]);
// Ensure other file types are allowed.
EXPECT_TRUE([panel allowsOtherFileTypes]);
}
// Verify that appropriate properties are set on the NSSavePanel for different
// dialog types.
TEST_F(SelectFileDialogMacTest, SelectionType) {
SelectFileDialog::FileTypeInfo file_type_info;
FileDialogArguments args;
args.file_types = &file_type_info;
enum {
HAS_ACCESSORY_VIEW = 1,
PICK_FILES = 2,
PICK_DIRS = 4,
CREATE_DIRS = 8,
MULTIPLE_SELECTION = 16,
};
struct SelectionTypeTestCase {
SelectFileDialog::Type type;
unsigned options;
std::string prompt;
} test_cases[] = {
{SelectFileDialog::SELECT_FOLDER, PICK_DIRS | CREATE_DIRS, "Select"},
{SelectFileDialog::SELECT_UPLOAD_FOLDER, PICK_DIRS, "Upload"},
{SelectFileDialog::SELECT_EXISTING_FOLDER, PICK_DIRS, "Select"},
{SelectFileDialog::SELECT_SAVEAS_FILE, CREATE_DIRS, "Save"},
{SelectFileDialog::SELECT_OPEN_FILE, PICK_FILES, "Open"},
{SelectFileDialog::SELECT_OPEN_MULTI_FILE,
PICK_FILES | MULTIPLE_SELECTION, "Open"},
};
for (size_t i = 0; i < base::size(test_cases); i++) {
SCOPED_TRACE(
base::StringPrintf("i=%lu file_dialog_type=%d", i, test_cases[i].type));
args.type = test_cases[i].type;
ResetDialog();
SelectFileWithParams(args);
NSSavePanel* panel = GetPanel();
EXPECT_EQ_BOOL(test_cases[i].options & HAS_ACCESSORY_VIEW,
[panel accessoryView]);
EXPECT_EQ_BOOL(test_cases[i].options & CREATE_DIRS,
[panel canCreateDirectories]);
EXPECT_EQ(test_cases[i].prompt, base::SysNSStringToUTF8([panel prompt]));
if (args.type != SelectFileDialog::SELECT_SAVEAS_FILE) {
NSOpenPanel* open_panel = base::mac::ObjCCast<NSOpenPanel>(panel);
// Verify that for types other than save file dialogs, an NSOpenPanel is
// created.
EXPECT_TRUE(open_panel);
EXPECT_EQ_BOOL(test_cases[i].options & PICK_FILES,
[open_panel canChooseFiles]);
EXPECT_EQ_BOOL(test_cases[i].options & PICK_DIRS,
[open_panel canChooseDirectories]);
EXPECT_EQ_BOOL(test_cases[i].options & MULTIPLE_SELECTION,
[open_panel allowsMultipleSelection]);
}
}
}
// Verify that the correct message is set on the NSSavePanel.
TEST_F(SelectFileDialogMacTest, DialogMessage) {
const std::string test_title = "test title";
FileDialogArguments args;
args.title = base::ASCIIToUTF16(test_title);
SelectFileWithParams(args);
EXPECT_EQ(test_title, base::SysNSStringToUTF8([GetPanel() message]));
}
// Verify that multiple file dialogs are correctly handled.
TEST_F(SelectFileDialogMacTest, MultipleDialogs) {
FileDialogArguments args;
SelectFileWithParams(args);
NSSavePanel* panel1 = GetPanel();
SelectFileWithParams(args);
NSSavePanel* panel2 = GetPanel();
EXPECT_EQ(2lu, GetActivePanelCount());
// Verify closing the panel decreases the panel count.
[panel1 cancel:nil];
base::RunLoop().RunUntilIdle();
EXPECT_EQ(1lu, GetActivePanelCount());
// In 10.15, file picker dialogs are remote, and the restriction of apps not
// being allowed to OK their own file requests has been extended from just
// sandboxed apps to all apps. If we can test OK-ing our own dialogs, sure,
// but if not, at least try to close them all.
if (base::mac::IsAtMostOS10_14())
[panel2 ok:nil];
else
[panel2 cancel:nil];
base::RunLoop().RunUntilIdle();
EXPECT_EQ(0lu, GetActivePanelCount());
}
// Verify that the default_path argument is respected.
TEST_F(SelectFileDialogMacTest, DefaultPath) {
FileDialogArguments args;
args.default_path = base::GetHomeDir().AppendASCII("test.txt");
SelectFileWithParams(args);
NSSavePanel* panel = GetPanel();
[panel setExtensionHidden:NO];
EXPECT_EQ(args.default_path.DirName(),
base::mac::NSStringToFilePath([[panel directoryURL] path]));
EXPECT_EQ(args.default_path.BaseName(),
base::mac::NSStringToFilePath([panel nameFieldStringValue]));
}
// Verify that the file dialog does not hide extension for filenames with
// multiple extensions.
TEST_F(SelectFileDialogMacTest, MultipleExtension) {
const std::string fake_path_normal = "/fake_directory/filename.tar";
const std::string fake_path_multiple = "/fake_directory/filename.tar.gz";
const std::string fake_path_long = "/fake_directory/example.com-123.json";
FileDialogArguments args;
args.default_path = base::FilePath(FILE_PATH_LITERAL(fake_path_normal));
SelectFileWithParams(args);
NSSavePanel* panel = GetPanel();
EXPECT_TRUE([panel canSelectHiddenExtension]);
EXPECT_TRUE([panel isExtensionHidden]);
ResetDialog();
args.default_path = base::FilePath(FILE_PATH_LITERAL(fake_path_multiple));
SelectFileWithParams(args);
panel = GetPanel();
EXPECT_FALSE([panel canSelectHiddenExtension]);
EXPECT_FALSE([panel isExtensionHidden]);
ResetDialog();
args.default_path = base::FilePath(FILE_PATH_LITERAL(fake_path_long));
SelectFileWithParams(args);
panel = GetPanel();
EXPECT_FALSE([panel canSelectHiddenExtension]);
EXPECT_FALSE([panel isExtensionHidden]);
}
// Verify that the file dialog does not hide extension when the
// `keep_extension_visible` flag is set to true.
TEST_F(SelectFileDialogMacTest, KeepExtensionVisible) {
const std::string extensions_arr[][2] = {{"html", "htm"}, {"jpeg", "jpg"}};
SelectFileDialog::FileTypeInfo file_type_info;
file_type_info.extensions.push_back(
GetVectorFromArray<std::string>(extensions_arr[0]));
file_type_info.extensions.push_back(
GetVectorFromArray<std::string>(extensions_arr[1]));
file_type_info.keep_extension_visible = true;
FileDialogArguments args;
args.file_types = &file_type_info;
SelectFileWithParams(args);
NSSavePanel* panel = GetPanel();
EXPECT_FALSE([panel canSelectHiddenExtension]);
EXPECT_FALSE([panel isExtensionHidden]);
}
// Test to ensure lifetime is sound if a reference to
// the panel outlives the delegate.
TEST_F(SelectFileDialogMacTest, Lifetime) {
base::scoped_nsobject<NSSavePanel> panel;
@autoreleasepool {
FileDialogArguments args;
// Set a type (Save dialogs do not have a delegate).
args.type = SelectFileDialog::SELECT_OPEN_MULTI_FILE;
SelectFileWithParams(args);
panel.reset([GetPanel() retain]);
EXPECT_TRUE([panel isVisible]);
EXPECT_NE(nil, [panel delegate]);
// Newer versions of AppKit may clear out weak delegate pointers when
// dealloc is called on the delegate. Put a ref into the autorelease pool to
// simulate what happens on older versions.
[[[panel delegate] retain] autorelease];
ResetDialog();
// The SelectFileDialogImpl destructor invokes [panel cancel]. That should
// close the panel, and run the completion handler.
EXPECT_EQ(nil, [panel delegate]);
EXPECT_FALSE([panel isVisible]);
}
EXPECT_EQ(nil, [panel delegate]);
}
} // namespace test
} // namespace ui