This repository has been archived by the owner on Dec 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 973
Adds state as param to currentWindow.js #10605
Merged
NejcZdovc
merged 1 commit into
brave:master
from
NejcZdovc:refactor/#10457-currentWindow
Sep 17, 2017
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
/* global describe, it, before */ | ||
const Immutable = require('immutable') | ||
const assert = require('assert') | ||
const currentWindow = require('../../../../app/renderer/currentWindow') | ||
|
||
describe('currentWindow unit test', function () { | ||
const windowId = 1 | ||
const state = Immutable.fromJS({ | ||
windows: [ | ||
{ | ||
windowId: windowId | ||
} | ||
] | ||
}) | ||
|
||
before(function () { | ||
currentWindow.setWindowId(windowId) | ||
}) | ||
|
||
describe('isMaximized', function () { | ||
it('null case', function () { | ||
const result = currentWindow.isMaximized(state, 2) | ||
assert.equal(result, false) | ||
}) | ||
|
||
it('false case', function () { | ||
const newState = state.setIn(['windows', 0, 'state'], 'test') | ||
const result = currentWindow.isMaximized(newState, windowId) | ||
assert.equal(result, false) | ||
}) | ||
|
||
it('true case', function () { | ||
const newState = state.setIn(['windows', 0, 'state'], 'maximized') | ||
const result = currentWindow.isMaximized(newState, windowId) | ||
assert.equal(result, true) | ||
}) | ||
}) | ||
|
||
describe('isFullScreen', function () { | ||
it('null case', function () { | ||
const result = currentWindow.isFullScreen(state, 2) | ||
assert.equal(result, false) | ||
}) | ||
|
||
it('false case', function () { | ||
const newState = state.setIn(['windows', 0, 'state'], 'test') | ||
const result = currentWindow.isFullScreen(newState, windowId) | ||
assert.equal(result, false) | ||
}) | ||
|
||
it('true case', function () { | ||
const newState = state.setIn(['windows', 0, 'state'], 'fullscreen') | ||
const result = currentWindow.isFullScreen(newState, windowId) | ||
assert.equal(result, true) | ||
}) | ||
}) | ||
|
||
describe('isFocused', function () { | ||
it('null case', function () { | ||
const result = currentWindow.isFocused(state, 2) | ||
assert.equal(result, false) | ||
}) | ||
|
||
it('not provided', function () { | ||
const result = currentWindow.isFocused(state, windowId) | ||
assert.equal(result, false) | ||
}) | ||
|
||
it('false case', function () { | ||
const newState = state.setIn(['windows', 0, 'focused'], false) | ||
const result = currentWindow.isFocused(newState, windowId) | ||
assert.equal(result, false) | ||
}) | ||
|
||
it('true case', function () { | ||
const newState = state.setIn(['windows', 0, 'focused'], true) | ||
const result = currentWindow.isFocused(newState, windowId) | ||
assert.equal(result, true) | ||
}) | ||
}) | ||
}) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maximized and fullscreen are only the same thing on macos. We should specify one or the other
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I preserved the same functionality, I didn't change anything. So it's working the same way it was before. The only thing that I changed is naming, because we had/have both things in it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm only referring to the naming. We have maximized and fullscreen in one property? That's a bit confusing imo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this is how we have it now 😃
browser-laptop/app/renderer/components/main/main.js
Line 533 in 6fe9849
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you propose? split it and use it separately?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the existing logic seems wrong to me because fullscreen and maximized should not be treated the same way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Current logic is working (no reports about any problems), so I would suggest that if it's not working we should open new issue for it. If we just want to refactor it we should open refactor issue. I think that this PR is not a right place to fix this, because we didn't introduced this naming in this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@NejcZdovc that seems fair but pls open an issue to track it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue created #10989