From d599b52d36bb3a91c28450501e3c85c2d36a2085 Mon Sep 17 00:00:00 2001 From: Jason Rudolph Date: Wed, 17 May 2017 15:25:08 -0400 Subject: [PATCH 1/4] :white_check_mark: Add failing tests for #14442 --- spec/dock-spec.js | 68 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/spec/dock-spec.js b/spec/dock-spec.js index 0608980fc..e2c289e55 100644 --- a/spec/dock-spec.js +++ b/spec/dock-spec.js @@ -62,6 +62,74 @@ describe('Dock', () => { }) }) + describe('activating the next pane', () => { + describe('when the dock has more than one pane', () => { + it('activates the next pane', () => { + jasmine.attachToDOM(atom.workspace.getElement()) + const dock = atom.workspace.getLeftDock() + const pane1 = dock.getPanes()[0] + const pane2 = pane1.splitRight() + const pane3 = pane2.splitRight() + pane2.activate() + expect(pane1.isActive()).toBe(false) + expect(pane2.isActive()).toBe(true) + expect(pane3.isActive()).toBe(false) + + dock.activateNextPane() + expect(pane1.isActive()).toBe(false) + expect(pane2.isActive()).toBe(false) + expect(pane3.isActive()).toBe(true) + }) + }) + + describe('when the dock has only one pane', () => { + it('leaves the current pane active', () => { + jasmine.attachToDOM(atom.workspace.getElement()) + const dock = atom.workspace.getLeftDock() + + expect(dock.getPanes().length).toBe(1) + const pane = dock.getPanes()[0] + expect(pane.isActive()).toBe(true) + dock.activateNextPane() + expect(pane.isActive()).toBe(true) + }) + }) + }) + + describe('activating the previous pane', () => { + describe('when the dock has more than one pane', () => { + it('activates the previous pane', () => { + jasmine.attachToDOM(atom.workspace.getElement()) + const dock = atom.workspace.getLeftDock() + const pane1 = dock.getPanes()[0] + const pane2 = pane1.splitRight() + const pane3 = pane2.splitRight() + pane2.activate() + expect(pane1.isActive()).toBe(false) + expect(pane2.isActive()).toBe(true) + expect(pane3.isActive()).toBe(false) + + dock.activatePreviousPane() + expect(pane1.isActive()).toBe(true) + expect(pane2.isActive()).toBe(false) + expect(pane3.isActive()).toBe(false) + }) + }) + + describe('when the dock has only one pane', () => { + it('leaves the current pane active', () => { + jasmine.attachToDOM(atom.workspace.getElement()) + const dock = atom.workspace.getLeftDock() + + expect(dock.getPanes().length).toBe(1) + const pane = dock.getPanes()[0] + expect(pane.isActive()).toBe(true) + dock.activatePreviousPane() + expect(pane.isActive()).toBe(true) + }) + }) + }) + describe('when the dock resize handle is double-clicked', () => { describe('when the dock is open', () => { it('resizes a vertically-oriented dock to the current item\'s preferred width', async () => { From ae9f24602d80cb15fe0edc15c1aae37d44ee786c Mon Sep 17 00:00:00 2001 From: Jason Rudolph Date: Wed, 17 May 2017 15:28:24 -0400 Subject: [PATCH 2/4] :bug: Fix #14442 Fixes error activating next/previous pane from Dock. --- src/dock.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/dock.js b/src/dock.js index 0e6d60e4e..d531e8627 100644 --- a/src/dock.js +++ b/src/dock.js @@ -626,6 +626,16 @@ module.exports = class Dock { return this.paneContainer.getActivePane() } + // Extended: Make the next pane active. + activateNextPane () { + return this.paneContainer.activateNextPane() + } + + // Extended: Make the previous pane active. + activatePreviousPane () { + return this.paneContainer.activatePreviousPane() + } + paneForURI (uri) { return this.paneContainer.paneForURI(uri) } From 8079b518397dc4dfa07e1aae73899f56b8d3326c Mon Sep 17 00:00:00 2001 From: Jason Rudolph Date: Fri, 19 May 2017 09:33:06 -0400 Subject: [PATCH 3/4] Remove unnecessary test setup H/T @nathansobo --- spec/dock-spec.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/spec/dock-spec.js b/spec/dock-spec.js index e2c289e55..2c2289447 100644 --- a/spec/dock-spec.js +++ b/spec/dock-spec.js @@ -65,7 +65,6 @@ describe('Dock', () => { describe('activating the next pane', () => { describe('when the dock has more than one pane', () => { it('activates the next pane', () => { - jasmine.attachToDOM(atom.workspace.getElement()) const dock = atom.workspace.getLeftDock() const pane1 = dock.getPanes()[0] const pane2 = pane1.splitRight() @@ -84,7 +83,6 @@ describe('Dock', () => { describe('when the dock has only one pane', () => { it('leaves the current pane active', () => { - jasmine.attachToDOM(atom.workspace.getElement()) const dock = atom.workspace.getLeftDock() expect(dock.getPanes().length).toBe(1) @@ -99,7 +97,6 @@ describe('Dock', () => { describe('activating the previous pane', () => { describe('when the dock has more than one pane', () => { it('activates the previous pane', () => { - jasmine.attachToDOM(atom.workspace.getElement()) const dock = atom.workspace.getLeftDock() const pane1 = dock.getPanes()[0] const pane2 = pane1.splitRight() @@ -118,7 +115,6 @@ describe('Dock', () => { describe('when the dock has only one pane', () => { it('leaves the current pane active', () => { - jasmine.attachToDOM(atom.workspace.getElement()) const dock = atom.workspace.getLeftDock() expect(dock.getPanes().length).toBe(1) From 3020a61e344fde603dcc57bff2bbfcb3a7e24abc Mon Sep 17 00:00:00 2001 From: Jason Rudolph Date: Fri, 19 May 2017 10:49:51 -0400 Subject: [PATCH 4/4] Test activating next/previous pane at the workspace level --- spec/workspace-spec.js | 56 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/spec/workspace-spec.js b/spec/workspace-spec.js index 6dc9d025d..9eaa17bcd 100644 --- a/spec/workspace-spec.js +++ b/spec/workspace-spec.js @@ -2528,6 +2528,62 @@ i = /test/; #FIXME\ }) }) + describe('::activateNextPane', () => { + describe('when the active workspace pane is inside a dock', () => { + it('activates the next pane in the dock', () => { + const dock = atom.workspace.getLeftDock() + const dockPane1 = dock.getPanes()[0] + const dockPane2 = dockPane1.splitRight() + + dockPane2.focus() + expect(atom.workspace.getActivePane()).toBe(dockPane2) + atom.workspace.activateNextPane() + expect(atom.workspace.getActivePane()).toBe(dockPane1) + }) + }) + + describe('when the active workspace pane is inside the workspace center', () => { + it('activates the next pane in the workspace center', () => { + const center = atom.workspace.getCenter() + const centerPane1 = center.getPanes()[0] + const centerPane2 = centerPane1.splitRight() + + centerPane2.focus() + expect(atom.workspace.getActivePane()).toBe(centerPane2) + atom.workspace.activateNextPane() + expect(atom.workspace.getActivePane()).toBe(centerPane1) + }) + }) + }) + + describe('::activatePreviousPane', () => { + describe('when the active workspace pane is inside a dock', () => { + it('activates the previous pane in the dock', () => { + const dock = atom.workspace.getLeftDock() + const dockPane1 = dock.getPanes()[0] + const dockPane2 = dockPane1.splitRight() + + dockPane1.focus() + expect(atom.workspace.getActivePane()).toBe(dockPane1) + atom.workspace.activatePreviousPane() + expect(atom.workspace.getActivePane()).toBe(dockPane2) + }) + }) + + describe('when the active workspace pane is inside the workspace center', () => { + it('activates the previous pane in the workspace center', () => { + const center = atom.workspace.getCenter() + const centerPane1 = center.getPanes()[0] + const centerPane2 = centerPane1.splitRight() + + centerPane1.focus() + expect(atom.workspace.getActivePane()).toBe(centerPane1) + atom.workspace.activatePreviousPane() + expect(atom.workspace.getActivePane()).toBe(centerPane2) + }) + }) + }) + describe('when the core.allowPendingPaneItems option is falsey', () => { it('does not open item with `pending: true` option as pending', () => { let pane = null