Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wagoodman committed Nov 28, 2019
1 parent e8301be commit 776c1f9
Show file tree
Hide file tree
Showing 13 changed files with 537 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- "/go/pkg/mod"
- run:
name: run static analysis
command: make ci-static-analyses
command: make ci-static-analysis

run-tests:
parameters:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
run: go get ./...

- name: Linting, formatting, and other static code analyses
run: make ci-static-analyses
run: make ci-static-analysis

- name: Build snapshot artifacts
run: make ci-build-snapshot-packages
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ all: clean build
ci-unit-test:
go test -cover -v -race ./...

ci-static-analyses:
ci-static-analysis:
grep -R 'const allowTestDataCapture = false' runtime/ui/viewmodel
go vet ./...
@! gofmt -s -l . 2>&1 | grep -vE '^\.git/' | grep -vE '^\.cache/'
Expand Down
4 changes: 4 additions & 0 deletions runtime/ui/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ func newApp(gui *gocui.Gui, analysis *image.AnalysisResult, cache filetree.Compa
lm.Add(compound.NewLayerDetailsCompoundLayout(controller.views.Layer, controller.views.Details), layout.LocationColumn)
lm.Add(controller.views.Tree, layout.LocationColumn)

// todo: access this more programmatically
if debug {
lm.Add(controller.views.Debug, layout.LocationColumn)
}
gui.Cursor = false
//g.Mouse = true
gui.SetManagerFunc(lm.Layout)
Expand Down
12 changes: 8 additions & 4 deletions runtime/ui/layout/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (lm *Manager) planAndLayoutColumns(g *gocui.Gui, area Area) (Area, error) {
}
}

defaultWidth := int(availableWidth / variableColumns)
defaultWidth := availableWidth / variableColumns

// second pass: layout columns left to right (based off predetermined widths)
for idx, element := range elements {
Expand Down Expand Up @@ -177,18 +177,22 @@ func (lm *Manager) notifyLayoutChange() error {
return nil
}

func (lm *Manager) Layout(g *gocui.Gui) error {
curMaxX, curMaxY := g.Size()
return lm.layout(g, curMaxX, curMaxY)
}

// layout defines the definition of the window pane size and placement relations to one another. This
// is invoked at application start and whenever the screen dimensions change.
// A few things to note:
// 1. gocui has borders around all views (even if Frame=false). This means there are a lot of +1/-1 magic numbers
// needed (but there are comments!).
// 2. since there are borders, in order for it to appear as if there aren't any spaces for borders, the views must
// overlap. To prevent screen artifacts, all elements must be layedout from the top of the screen to the bottom.
func (lm *Manager) Layout(g *gocui.Gui) error {
func (lm *Manager) layout(g *gocui.Gui, curMaxX, curMaxY int) error {
var headerAreaChanged, footerAreaChanged, columnAreaChanged bool

// grab the latest screen size and compare with the last layout
curMaxX, curMaxY := g.Size()
// compare current screen size with the last known size at time of layout
area := Area{
minX: -1,
minY: -1,
Expand Down
Loading

0 comments on commit 776c1f9

Please sign in to comment.