Skip to content

Commit

Permalink
test update for white speech bubble
Browse files Browse the repository at this point in the history
  • Loading branch information
Allie Crevier committed Aug 1, 2019
1 parent f605b40 commit 9a7a102
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
15 changes: 6 additions & 9 deletions securedrop_client/gui/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1293,7 +1293,7 @@ class SpeechBubble(QWidget):
"""

CSS = '''
#speech-bubble {
#speech_bubble {
font-family: 'Source Sans Pro';
font-weight: 400;
font-size: 15px;
Expand All @@ -1303,7 +1303,7 @@ class SpeechBubble(QWidget):
border-bottom: 0;
background-color: #fff;
}
#color-bar {
#color_bar {
padding: 0px;
background-color: #102781;
min-height: 5px;
Expand All @@ -1322,13 +1322,13 @@ def __init__(self, message_id: str, text: str, update_signal) -> None:
layout.setSpacing(0)
self.setLayout(layout)
self.message = SecureQLabel(text)
self.message.setObjectName('speech-bubble')
self.message.setObjectName('speech_bubble')
self.message.setWordWrap(True)
self.message.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
layout.addWidget(self.message)

self.color_bar = QWidget()
self.color_bar.setObjectName('color-bar')
self.color_bar.setObjectName('color_bar')
self.color_bar.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
layout.addWidget(self.color_bar)

Expand Down Expand Up @@ -1397,11 +1397,11 @@ class ReplyWidget(ConversationWidget):
"""

CSS_COLOR_BAR_REPLY_FAIL = '''
background-color: #ff3366;
background_color: #ff3366;
'''

CSS_COLOR_BAR_REPLY = '''
background-color: #0065db;
background_color: #0065db;
'''

def __init__(
Expand All @@ -1418,9 +1418,6 @@ def __init__(
align="right")
self.message_id = message_id

# Set css id
self.setObjectName('reply-widget')

# Set styles
self.speech_bubble.color_bar.setStyleSheet(self.CSS_COLOR_BAR_REPLY)

Expand Down
13 changes: 6 additions & 7 deletions tests/gui/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1101,9 +1101,12 @@ def test_SpeechBubble_init(mocker):
mock_connect = mocker.Mock()
mock_signal.connect = mock_connect

SpeechBubble('mock id', 'hello', mock_signal)
sb = SpeechBubble('mock id', 'hello', mock_signal)
ss = sb.styleSheet()

mock_label.assert_called_once_with('hello')
assert mock_connect.called
assert 'background-color' in ss


def test_SpeechBubble_update_text(mocker):
Expand Down Expand Up @@ -1186,10 +1189,8 @@ def test_MessageWidget_init(mocker):
mock_connected = mocker.Mock()
mock_signal.connect = mock_connected

mw = MessageWidget('mock id', 'hello', mock_signal)
ss = mw.styleSheet()
MessageWidget('mock id', 'hello', mock_signal)

assert 'background-color' in ss
assert mock_connected.called


Expand All @@ -1209,16 +1210,14 @@ def test_ReplyWidget_init(mocker):
mock_failure_connected = mocker.Mock()
mock_failure_signal.connect = mock_failure_connected

rw = ReplyWidget(
ReplyWidget(
'mock id',
'hello',
mock_update_signal,
mock_success_signal,
mock_failure_signal,
)
ss = rw.styleSheet()

assert 'background-color' in ss
assert mock_update_connected.called
assert mock_success_connected.called
assert mock_failure_connected.called
Expand Down

0 comments on commit 9a7a102

Please sign in to comment.