Merge lp:~osomon/webbrowser-app/fix-ap-failures-desktop-narrow into lp:webbrowser-app

Proposed by Olivier Tilloy on 2015-12-03
Status: Merged
Approved by: Olivier Tilloy on 2015-12-04
Approved revision: 1296
Merged at revision: 1295
Proposed branch: lp:~osomon/webbrowser-app/fix-ap-failures-desktop-narrow
Merge into: lp:webbrowser-app
Diff against target: 160 lines (+51/-14)
4 files modified
src/app/webbrowser/Browser.qml (+4/-4)
src/app/webbrowser/tabs-model.cpp (+3/-1)
tests/autopilot/webbrowser_app/tests/test_tabs.py (+8/-9)
tests/unittests/tabs-model/tst_TabsModelTests.cpp (+36/-0)
To merge this branch: bzr merge lp:~osomon/webbrowser-app/fix-ap-failures-desktop-narrow
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve on 2015-12-03
Ubuntu Phablet Team 2015-12-03 Pending
Review via email: mp+279427@code.launchpad.net

Commit Message

Fix 3 autopilot test failures on desktop in narrow mode.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/app/webbrowser/Browser.qml'
2--- src/app/webbrowser/Browser.qml 2015-11-26 11:59:33 +0000
3+++ src/app/webbrowser/Browser.qml 2015-12-03 12:08:41 +0000
4@@ -1365,7 +1365,7 @@
5 if (!incognito && closedTabHistory.length > 0) {
6 var tabInfo = closedTabHistory.pop()
7 var tab = session.createTabFromState(tabInfo.state)
8- internal.addTab(tab, true, tabInfo.index)
9+ addTab(tab, true, tabInfo.index)
10 }
11 }
12
13@@ -1375,7 +1375,6 @@
14 } else {
15 internal.switchToTab(tabsModel.count - 1, true)
16 }
17- if (recentView.visible) recentView.focus = true
18 }
19
20 function switchToNextTab() {
21@@ -1384,7 +1383,6 @@
22 } else {
23 internal.switchToTab(tabsModel.count - 1, true)
24 }
25- if (recentView.visible) recentView.focus = true
26 }
27
28 function switchToTab(index, delayed) {
29@@ -1395,7 +1393,9 @@
30 tabsModel.currentIndex = index
31 nextTabIndex = -1
32 var tab = tabsModel.currentTab
33- if (tab) {
34+ if (recentView.visible) {
35+ recentView.focus = true
36+ } else if (tab) {
37 if (!tab.url.toString() && !tab.initialUrl.toString() &&
38 (formFactor == "desktop")) {
39 focusAddressBar()
40
41=== modified file 'src/app/webbrowser/tabs-model.cpp'
42--- src/app/webbrowser/tabs-model.cpp 2015-09-23 16:50:21 +0000
43+++ src/app/webbrowser/tabs-model.cpp 2015-12-03 12:08:41 +0000
44@@ -148,7 +148,9 @@
45 m_currentIndex = 0;
46 Q_EMIT currentIndexChanged();
47 Q_EMIT currentTabChanged();
48- } else if (index <= m_currentIndex) {
49+ } else if (index == m_currentIndex) {
50+ Q_EMIT currentTabChanged();
51+ } else if (index < m_currentIndex) {
52 // Increment the index if we are inserting items before the current index.
53 m_currentIndex++;
54 Q_EMIT currentIndexChanged();
55
56=== modified file 'tests/autopilot/webbrowser_app/tests/test_tabs.py'
57--- tests/autopilot/webbrowser_app/tests/test_tabs.py 2015-11-11 16:03:56 +0000
58+++ tests/autopilot/webbrowser_app/tests/test_tabs.py 2015-12-03 12:08:41 +0000
59@@ -282,10 +282,9 @@
60
61 @testtools.skipIf(model() != "Desktop", "on desktop only")
62 def test_undo_close_tab(self):
63- tabs = self.main_window.chrome.get_tabs_bar()
64 url0 = self.main_window.get_current_webview().url
65
66- self.open_new_tab()
67+ self.open_new_tab(open_tabs_view=not self.main_window.wide)
68 url1 = self.base_url + "/tab/1"
69 self.main_window.go_to_url(url1)
70 self.main_window.wait_until_page_loaded(url1)
71@@ -293,19 +292,19 @@
72
73 # Insert a "new tab view" page in the middle, without any page loaded
74 # so that we can verify that it will not be restored
75- self.open_new_tab()
76+ self.open_new_tab(open_tabs_view=not self.main_window.wide)
77
78- self.open_new_tab()
79+ self.open_new_tab(open_tabs_view=not self.main_window.wide)
80 url2 = self.base_url + "/tab/2"
81 self.main_window.go_to_url(url2)
82 self.main_window.wait_until_page_loaded(url2)
83 self.assert_number_webviews_eventually(4)
84
85- tabs.close_tab(3)
86+ self.main_window.press_key('Ctrl+w')
87 self.assert_number_webviews_eventually(3)
88- tabs.close_tab(2)
89+ self.main_window.press_key('Ctrl+w')
90 self.assert_number_webviews_eventually(2)
91- tabs.close_tab(1)
92+ self.main_window.press_key('Ctrl+w')
93 self.assert_number_webviews_eventually(1)
94 self.check_current_tab(url0)
95
96@@ -325,7 +324,7 @@
97 @testtools.skipIf(model() != "Desktop", "on desktop only")
98 def test_undo_close_tab_incognito(self):
99 start_url = self.main_window.get_current_webview().url
100- self.open_new_tab()
101+ self.open_new_tab(open_tabs_view=not self.main_window.wide)
102 url = self.base_url + "/tab/1"
103 self.main_window.go_to_url(url)
104 self.main_window.wait_until_page_loaded(url)
105@@ -341,7 +340,7 @@
106 self.main_window.go_to_url(incognito_url)
107 self.main_window.wait_until_page_loaded(incognito_url)
108
109- self.open_new_tab()
110+ self.open_new_tab(open_tabs_view=not self.main_window.wide)
111 self.main_window.go_to_url(incognito_url)
112 self.main_window.wait_until_page_loaded(incognito_url)
113 self.main_window.press_key('Ctrl+w')
114
115=== modified file 'tests/unittests/tabs-model/tst_TabsModelTests.cpp'
116--- tests/unittests/tabs-model/tst_TabsModelTests.cpp 2015-09-23 17:14:30 +0000
117+++ tests/unittests/tabs-model/tst_TabsModelTests.cpp 2015-12-03 12:08:41 +0000
118@@ -336,6 +336,42 @@
119 QCOMPARE(model->currentTab(), tab1);
120 }
121
122+ void shouldUpdateCurrentTabWhenInsertingAtCurrentIndex()
123+ {
124+ QQuickItem* tab1 = createTab();
125+ model->insert(tab1, 0);
126+ QCOMPARE(model->currentIndex(), 0);
127+ QCOMPARE(model->currentTab(), tab1);
128+
129+ QSignalSpy spytab(model, SIGNAL(currentTabChanged()));
130+ QSignalSpy spyindex(model, SIGNAL(currentIndexChanged()));
131+
132+ QQuickItem* tab2 = createTab();
133+ model->insert(tab2, 0);
134+
135+ QVERIFY(spyindex.isEmpty());
136+ QCOMPARE(spytab.count(), 1);
137+ QCOMPARE(model->currentTab(), tab2);
138+ }
139+
140+ void shouldUpdateCurrentIndexWhenInsertingBeforeCurrentIndex()
141+ {
142+ model->insert(createTab(), 0);
143+ model->insert(createTab(), 0);
144+ model->setCurrentIndex(1);
145+ QObject* current = model->currentTab();
146+
147+ QSignalSpy spytab(model, SIGNAL(currentTabChanged()));
148+ QSignalSpy spyindex(model, SIGNAL(currentIndexChanged()));
149+
150+ model->insert(createTab(), 0);
151+
152+ QVERIFY(spytab.isEmpty());
153+ QCOMPARE(spyindex.count(), 1);
154+ QCOMPARE(model->currentTab(), current);
155+ QCOMPARE(model->currentIndex(), 2);
156+ }
157+
158 void shouldSetInvalidIndexWhenRemovingLastTab()
159 {
160 // Removing the last item should also set the current index to -1

Subscribers

People subscribed via source and target branches

to status/vote changes: