team-ljyzipelo

공개

미리보기의 전체 목록 처리 예산 승인을 요청한다

작성자
호시노 히나타
작성 시각
커밋
6a349a7385a3db6b6814d132e2c419417ad1161d
부모
715e962
이 시점의 파일 보기

변경된 파일 6개

+156-1
수정docs/ui-scenario-guide.md+1-0
@@ -150,6 +150,7 @@ Ubuntu 제거 안내는 패키지 관리자 터미널 출력입니다. 이전
150150
151151### 파일 미리보기
152152
153추가: - preview-catalog-approval: 10,001개 목록에서 파일 하나를 미리볼 때 목록 전체 처리 예산의 새 승인을 요청. 텍스트 1 MiB와 이미지 8 MiB 고유 상한은 유지.
153154- preview-loading: 미리보기 로딩 중 [취소] 또는 Esc로 닫기. 닫힌 결과는 늦게 도착해도 표시하지 않음.
154155- preview-text: UTF-8 텍스트의 읽기 전용 표시와 스크롤.
155156- preview-image: 디코딩된 정적 이미지의 화면 맞춤 표시.
수정experiments/rust-ui-memory-app/src/archive_ui.rs+1-1
@@ -501,7 +501,7 @@ impl Model {
501501 .flatten();
502502 }
503503 Start::Preview { entry_id, .. } => {
504삭제: usage.estimated_entries = Some(1);
504추가: usage.estimated_entries = u32::try_from(self.entries.len()).ok();
505505 usage.estimated_bytes = self
506506 .entries
507507 .iter()
수정tests/rust-app-real-worker/flows.rs+2-0
@@ -697,3 +697,5 @@ fn cancel_racing_exit_without_terminal_remains_unconfirmed() {
697697}
698698
699699mod guarded_flows;
700추가:
701추가: mod preview_catalog;
추가tests/rust-app-real-worker/preview_catalog.rs+110-0
@@ -0,0 +1,110 @@
1추가: use super::*;
2추가:
3추가: fn finish_preview_catalog(model: &mut Model, allow: bool) -> usize {
4추가: let deadline = Instant::now() + Duration::from_secs(30);
5추가: let mut questions = 0;
6추가: while model.busy() {
7추가: model.poll();
8추가: if let Some(question) = model.resource.clone() {
9추가: assert!(question.scope.entries);
10추가: assert!(!question.scope.ratio);
11추가: assert_eq!(question.action, ActionKind::Preview);
12추가: assert_eq!(model.estimated_usage().estimated_entries, Some(10_001));
13추가: assert!(model.resource_reply(model.job_id().unwrap(), question.id, allow));
14추가: questions += 1;
15추가: }
16추가: assert!(Instant::now() < deadline, "{:?}", model.error);
17추가: std::thread::sleep(Duration::from_millis(1));
18추가: }
19추가: assert!(model.error.is_none(), "{:?}", model.error);
20추가: questions
21추가: }
22추가:
23추가: fn preview_catalog(count: usize, bytes: usize, allow: bool, image: bool) {
24추가: let name = if image { "small.png" } else { "small.txt" };
25추가: let scratch = Scratch::new();
26추가: let archive = scratch.path("many.zip");
27추가: let generated = std::process::Command::new("python3")
28추가: .arg("-c")
29추가: .arg("import sys,zipfile; z=zipfile.ZipFile(sys.argv[1], 'w'); z.writestr(sys.argv[4], b'x'*int(sys.argv[3])); [z.writestr(f'{i}.bin', b'') for i in range(int(sys.argv[2])-1)]; z.close()")
30추가: .arg(&archive)
31추가: .arg(count.to_string())
32추가: .arg(bytes.to_string())
33추가: .arg(name)
34추가: .output()
35추가: .unwrap();
36추가: assert!(generated.status.success());
37추가: let mut factory = ProcessFactory::new(binary("zipelo-archive-worker"));
38추가: let mut model = Model::default();
39추가: assert!(model.begin(Start::List { archive }, &mut factory));
40추가: wait(&mut model);
41추가: if count > 10_000 {
42추가: assert_eq!(
43추가: model.terminal.as_ref().unwrap().error,
44추가: Some(ErrorCode::Limit)
45추가: );
46추가: assert!(model.retry_expanded(&mut factory));
47추가: let deadline = Instant::now() + Duration::from_secs(30);
48추가: while model.busy() {
49추가: model.poll();
50추가: if let Some(question) = model.resource.clone() {
51추가: assert!(model.resource_reply(model.job_id().unwrap(), question.id, true));
52추가: }
53추가: assert!(Instant::now() < deadline);
54추가: std::thread::sleep(Duration::from_millis(1));
55추가: }
56추가: }
57추가: completed(&model);
58추가: assert_eq!(model.entries.len(), count);
59추가: let id = model
60추가: .entries
61추가: .iter()
62추가: .find(|entry| entry.name == name)
63추가: .unwrap()
64추가: .id;
65추가: model.selected.insert(id);
66추가: assert!(model.begin_preview(&mut factory));
67추가: let questions = finish_preview_catalog(&mut model, allow);
68추가: assert_eq!(questions, usize::from(count > 10_000));
69추가: if !allow {
70추가: assert!(model.preview.is_none());
71추가: assert_ne!(model.terminal.as_ref().unwrap().outcome, Outcome::Completed);
72추가: } else if bytes > if image { 8 * 1024 * 1024 } else { 1024 * 1024 } {
73추가: assert_eq!(
74추가: model.terminal.as_ref().unwrap().error,
75추가: Some(ErrorCode::Limit)
76추가: );
77추가: assert!(model.preview.is_none());
78추가: assert!(!model.can_retry_expanded());
79추가: } else {
80추가: completed(&model);
81추가: assert_eq!(model.preview.as_ref().unwrap().data, vec![b'x'; bytes]);
82추가: }
83추가: assert!(model.outputs.is_empty());
84추가: assert_eq!(model.selected, [id].into_iter().collect());
85추가: }
86추가:
87추가: #[test]
88추가: fn preview_catalog_at_default_entry_limit_needs_no_approval() {
89추가: preview_catalog(10_000, 7, true, false);
90추가: }
91추가:
92추가: #[test]
93추가: fn preview_catalog_over_default_entry_limit_requires_new_approval() {
94추가: preview_catalog(10_001, 7, true, false);
95추가: }
96추가:
97추가: #[test]
98추가: fn preview_catalog_approval_does_not_raise_text_size_limit() {
99추가: preview_catalog(10_001, 1024 * 1024 + 1, true, false);
100추가: }
101추가:
102추가: #[test]
103추가: fn preview_catalog_denial_does_not_show_data() {
104추가: preview_catalog(10_001, 7, false, false);
105추가: }
106추가:
107추가: #[test]
108추가: fn preview_catalog_approval_does_not_raise_image_size_limit() {
109추가: preview_catalog(10_001, 8 * 1024 * 1024 + 1, true, true);
110추가: }
수정tests/rust-app-ui/scenario_tests.rs+1-0
@@ -97,6 +97,7 @@ fn every_listed_scenario_draws_and_keeps_its_expected_screen() {
9797 assert!(app.model.input_error.is_none(), "{}", scenario.name);
9898 let expected = match scenario.name {
9999 "preview-implicit-folder" => "자료",
100추가: "preview-catalog-approval" => "큰 작업을 허용할까요?",
100101 "preview-loading" => "미리보기를 불러오는 중입니다",
101102 "preview-text" => "여행 준비 목록",
102103 "preview-image" => "미리보기",
수정tests/rust-app-ui/scenarios.rs+41-0
@@ -21,6 +21,7 @@ macro_rules! catalog {
2121}
2222
2323catalog! {
24추가: "preview-catalog-approval" => "미리보기의 전체 목록 처리 예산 승인",
2425 "preview-loading" => "미리보기 로딩과 취소",
2526 "preview-text" => "읽기 전용 텍스트 미리보기",
2627 "preview-image" => "정적 이미지 미리보기",
@@ -273,7 +274,47 @@ impl Scenario {
273274 app.model.selected.insert(0);
274275 return app;
275276 }
277추가: if self.name == "preview-catalog-approval" {
278추가: let template = app.model.entries[1].clone();
279추가: app.model.entries = (0..10_001)
280추가: .map(|id| Entry {
281추가: id,
282추가: name: if id == 1 {
283추가: "읽어주세요.txt".into()
284추가: } else {
285추가: format!("{id}.bin")
286추가: },
287추가: bytes: Some(if id == 1 { 7 } else { 0 }),
288추가: ..template.clone()
289추가: })
290추가: .collect();
291추가: }
276292 app.begin_preview(&egui::Context::default());
293추가: if self.name == "preview-catalog-approval" {
294추가: let mut state = state.borrow_mut();
295추가: state.frame(Event::Accepted { encryption: false });
296추가: state.frame(Event::ResourceRequired(ResourceChallenge {
297추가: id: 1,
298추가: action: ActionKind::Preview,
299추가: scope: ResourceScope {
300추가: output: true,
301추가: entries: true,
302추가: ..ResourceScope::default()
303추가: },
304추가: usage: ResourceUsage::default(),
305추가: soft_limits: Limits::default(),
306추가: ceiling: Limits {
307추가: input: u64::MAX,
308추가: output: 64 * 1024 * 1024 * 1024,
309추가: entries: 200_000,
310추가: },
311추가: }));
312추가: drop(state);
313추가: for _ in 0..32 {
314추가: app.model.poll();
315추가: }
316추가: return app;
317추가: }
277318 {
278319 let mut state = state.borrow_mut();
279320 state.frame(Event::Accepted { encryption: false });