Skip to content

Commit abdfff7

Browse files
shai-almogclaude
andcommitted
ChatView / ChatInput screenshot tests: install the modern theme
Both tests previously extended `BaseTest`, which renders against whatever theme is currently installed -- and that's the legacy iOS 7 / Android Holo Light default. So the new ChatBubble*/ ChatInput* UIIDs I styled in `native-themes/{ios-modern, android-material}/theme.css` never reached the rendered screenshot, and the bubbles came out unstyled. Switch both tests to `DualAppearanceBaseTest`, which is the existing mechanism used by the other theme-fidelity tests (SpanLabelThemeScreenshotTest, ButtonThemeScreenshotTest, etc.). It: 1. Installs the modern native theme via UIManager.setThemeProps from the .res shipped alongside the test resources. 2. Drives two captures per test: `_light` (CN.isDarkMode()=false) and `_dark` (true), refreshing the theme between them so the prefers-color-scheme @media block lights up the $DarkChatBubble* entries we already emit. Same content (system + user + assistant + streaming + typing indicator for ChatView, attach+voice+send for ChatInput), just routed through the dual-appearance harness so the ChatBubble UIIDs actually render. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 43e3044 commit abdfff7

2 files changed

Lines changed: 39 additions & 27 deletions

File tree

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,30 @@
11
package com.codenameone.examples.hellocodenameone.tests;
22

33
import com.codename1.components.ChatInput;
4-
import com.codename1.ui.Container;
54
import com.codename1.ui.Form;
65
import com.codename1.ui.events.ActionEvent;
76
import com.codename1.ui.events.ActionListener;
87
import com.codename1.ui.layouts.BorderLayout;
8+
import com.codename1.ui.layouts.Layout;
99

10-
/// Renders ChatInput with attach + voice + send affordances all visible.
11-
/// Baselines the ChatInputField / ChatSendButton / ChatAttachButton /
12-
/// ChatVoiceButton UIIDs.
13-
public class ChatInputScreenshotTest extends BaseTest {
10+
/// ChatInput screenshot: attach + voice + send affordances all visible.
11+
/// Baselines the ChatInput / ChatInputField / ChatSendButton /
12+
/// ChatAttachButton / ChatVoiceButton UIIDs in both modern theme
13+
/// appearances (light + dark via DualAppearanceBaseTest).
14+
public class ChatInputScreenshotTest extends DualAppearanceBaseTest {
1415

1516
@Override
16-
public boolean runTest() {
17-
Form form = createForm("ChatInput", new BorderLayout(), "ChatInput");
17+
protected String baseName() {
18+
return "ChatInput";
19+
}
20+
21+
@Override
22+
protected Layout newLayout() {
23+
return new BorderLayout();
24+
}
25+
26+
@Override
27+
protected void populate(Form form, String suffix) {
1828
ChatInput input = new ChatInput();
1929
// Setters install ActionListener -> button becomes visible. Use no-op
2030
// listeners; this is a layout test, not an interaction test.
@@ -26,10 +36,6 @@ public void actionPerformed(ActionEvent evt) {
2636
input.setOnSend(noop);
2737
input.setOnAttach(noop);
2838
input.setOnVoice(noop);
29-
30-
Container body = (Container) form.getContentPane();
31-
body.add(BorderLayout.SOUTH, input);
32-
form.show();
33-
return true;
39+
form.add(BorderLayout.SOUTH, input);
3440
}
3541
}

scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/tests/ChatViewScreenshotTest.java

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,31 @@
22

33
import com.codename1.ai.ChatMessage;
44
import com.codename1.components.ChatView;
5-
import com.codename1.ui.Container;
65
import com.codename1.ui.Form;
76
import com.codename1.ui.layouts.BorderLayout;
7+
import com.codename1.ui.layouts.Layout;
88

9-
/// Renders ChatView with a representative system+user+assistant exchange
10-
/// plus the typing indicator visible. Baselines this PR's new AI UI surface
11-
/// against iOS Modern + Android Material themes (the existing
12-
/// build-ios-metal / build-ios / Build Android screenshot jobs pick up the
13-
/// emitted "ChatView" image automatically).
14-
public class ChatViewScreenshotTest extends BaseTest {
15-
private ChatView chat;
9+
/// ChatView screenshot: representative system + user + assistant
10+
/// exchange with the typing indicator visible. Baselines ChatBubbleUser,
11+
/// ChatBubbleAssistant, ChatBubbleSystem, ChatBubbleText, and
12+
/// ChatTypingIndicator UIIDs against iOS Modern + Android Material
13+
/// modern themes (emits a `_light` and `_dark` pair, like the other
14+
/// theme-fidelity tests in this directory).
15+
public class ChatViewScreenshotTest extends DualAppearanceBaseTest {
1616

1717
@Override
18-
public boolean runTest() {
19-
Form form = createForm("ChatView", new BorderLayout(), "ChatView");
20-
chat = new ChatView();
18+
protected String baseName() {
19+
return "ChatView";
20+
}
21+
22+
@Override
23+
protected Layout newLayout() {
24+
return new BorderLayout();
25+
}
26+
27+
@Override
28+
protected void populate(Form form, String suffix) {
29+
ChatView chat = new ChatView();
2130

2231
// System framing (small grey bubble centred).
2332
chat.addMessage(ChatMessage.system("AI Travel Assistant"));
@@ -39,9 +48,6 @@ public boolean runTest() {
3948
// Typing indicator visible -- exercises the dots animation styling.
4049
chat.setTypingIndicatorVisible(true);
4150

42-
Container body = (Container) form.getContentPane();
43-
body.add(BorderLayout.CENTER, chat);
44-
form.show();
45-
return true;
51+
form.add(BorderLayout.CENTER, chat);
4652
}
4753
}

0 commit comments

Comments
 (0)