Merge lp:~3v1n0/unity/fix-panel-redraw-no-menus into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Brandon Schaefer
Approved revision: no longer in the source branch.
Merged at revision: 2991
Proposed branch: lp:~3v1n0/unity/fix-panel-redraw-no-menus
Merge into: lp:unity
Prerequisite: lp:~3v1n0/unity/wbuttons-properties-tests
Diff against target: 98 lines (+24/-21)
2 files modified
panel/PanelMenuView.cpp (+2/-0)
tests/test_panel_menu_view.cpp (+22/-21)
To merge this branch: bzr merge lp:~3v1n0/unity/fix-panel-redraw-no-menus
Reviewer Review Type Date Requested Status
Brandon Schaefer (community) Approve
PS Jenkins bot continuous-integration Pending
Review via email: mp+139960@code.launchpad.net

Commit message

PanelMenuView: force a queuedraw when the buttons opacity changes

Description of the change

The panel needs to be redrawn when the buttons opacity changes... Easy fix, nice new test :)

To post a comment you must log in.
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Cool works here.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'panel/PanelMenuView.cpp'
2--- panel/PanelMenuView.cpp 2012-12-14 16:53:00 +0000
3+++ panel/PanelMenuView.cpp 2012-12-14 16:53:00 +0000
4@@ -105,6 +105,8 @@
5
6 window_buttons_->mouse_enter.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseEnter));
7 window_buttons_->mouse_leave.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseLeave));
8+ /* This is needed since when buttons are redrawn, the panel is not. See bug #1090439 */
9+ window_buttons_->opacity.changed.connect(sigc::hide(sigc::mem_fun(this, &PanelMenuView::QueueDraw)));
10 AddChild(window_buttons_.GetPointer());
11
12 layout_->SetLeftAndRightPadding(window_buttons_->GetContentWidth(), 0);
13
14=== modified file 'tests/test_panel_menu_view.cpp'
15--- tests/test_panel_menu_view.cpp 2012-12-14 16:53:00 +0000
16+++ tests/test_panel_menu_view.cpp 2012-12-14 16:53:00 +0000
17@@ -31,15 +31,6 @@
18 namespace unity
19 {
20
21-class MockPanelMenuView : public PanelMenuView
22-{
23- protected:
24- virtual std::string GetActiveViewName(bool use_appname) const
25- {
26- return "<>'";
27- }
28-};
29-
30 struct TestPanelMenuView : public testing::Test
31 {
32 void ProcessUBusMessages()
33@@ -50,24 +41,28 @@
34 Utils::WaitUntil(expired);
35 }
36
37- std::string panelTitle() const
38+ struct MockPanelMenuView : public PanelMenuView
39 {
40- const PanelMenuView *panel = &panelMenuView;
41- return panel->GetCurrentTitle();
42- }
43-
44-private:
45- // The order is important, i.e. PanelMenuView needs
46+ MOCK_METHOD0(QueueDraw, void());
47+ MOCK_CONST_METHOD1(GetActiveViewName, std::string(bool));
48+
49+ using PanelMenuView::window_buttons_;
50+ using PanelMenuView::GetCurrentTitle;
51+ };
52+
53+protected:
54+ // The order is important, i.e. menu_view needs
55 // panel::Style that needs Settings
56 Settings settings;
57 panel::Style panelStyle;
58- MockPanelMenuView panelMenuView;
59+ testing::NiceMock<MockPanelMenuView> menu_view;
60 };
61
62 TEST_F(TestPanelMenuView, Escaping)
63 {
64+ ON_CALL(menu_view, GetActiveViewName(testing::_)).WillByDefault(Return("<>'"));
65 static const char *escapedText = "Panel d&amp;Inici";
66- EXPECT_TRUE(panelTitle().empty());
67+ EXPECT_TRUE(menu_view.GetCurrentTitle().empty());
68
69 UBusManager ubus;
70 ubus.SendMessage(UBUS_LAUNCHER_START_KEY_NAV, NULL);
71@@ -75,18 +70,24 @@
72 g_variant_new_string(escapedText));
73 ProcessUBusMessages();
74
75- EXPECT_EQ(panelTitle(), escapedText);
76+ EXPECT_EQ(menu_view.GetCurrentTitle(), escapedText);
77
78 ubus.SendMessage(UBUS_LAUNCHER_END_KEY_NAV, NULL);
79 ProcessUBusMessages();
80
81 StandaloneWindowManager *wm = dynamic_cast<StandaloneWindowManager *>(&WindowManager::Default());
82 ASSERT_NE(wm, nullptr);
83- // Change the wm to trick PanelMenuView::RefreshTitle to call GetActiveViewName
84+ // Change the wm to trick menu_view::RefreshTitle to call GetActiveViewName
85 wm->SetScaleActive(true);
86 wm->SetScaleActiveForGroup(true);
87
88- EXPECT_EQ(panelTitle(), "&lt;&gt;&apos;");
89+ EXPECT_EQ(menu_view.GetCurrentTitle(), "&lt;&gt;&apos;");
90+}
91+
92+TEST_F(TestPanelMenuView, QueuesDrawOnButtonsOpacityChange)
93+{
94+ EXPECT_CALL(menu_view, QueueDraw());
95+ menu_view.window_buttons_->opacity.changed.emit(0.5f);
96 }
97
98 }