spec: Fix failing tests on Windows

This commit is contained in:
Cheng Zhao 2016-01-23 20:03:56 +08:00
parent 8239f69139
commit cc560a3900
2 changed files with 16 additions and 4 deletions

View file

@ -158,7 +158,7 @@ NativeWindowViews::NativeWindowViews(
// The given window is most likely not rectangular since it uses // The given window is most likely not rectangular since it uses
// transparency and has no standard frame, don't show a shadow for it. // transparency and has no standard frame, don't show a shadow for it.
if (transparent() && !has_frame()) if (transparent() && !has_frame())
params.shadow_type = Widget::InitParams::SHADOW_TYPE_NONE; params.shadow_type = views::Widget::InitParams::SHADOW_TYPE_NONE;
#if defined(OS_WIN) #if defined(OS_WIN)
params.native_widget = params.native_widget =
@ -441,7 +441,11 @@ void NativeWindowViews::SetResizable(bool resizable) {
} }
bool NativeWindowViews::IsResizable() { bool NativeWindowViews::IsResizable() {
#if defined(OS_WIN)
return ::GetWindowLong(GetAcceleratedWidget(), GWL_STYLE) & WS_THICKFRAME;
#else
return CanResize(); return CanResize();
#endif
} }
void NativeWindowViews::SetMovable(bool movable) { void NativeWindowViews::SetMovable(bool movable) {
@ -598,7 +602,9 @@ void NativeWindowViews::SetBackgroundColor(const std::string& color_name) {
} }
void NativeWindowViews::SetHasShadow(bool has_shadow) { void NativeWindowViews::SetHasShadow(bool has_shadow) {
wm::SetShadowType(GetNativeWindow(), wm::SHADOW_TYPE_NONE); wm::SetShadowType(
GetNativeWindow(),
has_shadow ? wm::SHADOW_TYPE_RECTANGULAR : wm::SHADOW_TYPE_NONE);
} }
bool NativeWindowViews::HasShadow() { bool NativeWindowViews::HasShadow() {

View file

@ -597,13 +597,19 @@ describe('browser-window module', function() {
}); });
describe('hasShadow state', function() { describe('hasShadow state', function() {
// On Window there is no shadow by default and it can not be changed
// dynamically.
it('can be changed with hasShadow option', function() { it('can be changed with hasShadow option', function() {
w.destroy(); w.destroy();
w = new BrowserWindow({show: false, hasShadow: false}); let hasShadow = process.platform == 'darwin' ? false : true;
assert.equal(w.hasShadow(), false); w = new BrowserWindow({show: false, hasShadow: hasShadow});
assert.equal(w.hasShadow(), hasShadow);
}); });
it('can be changed with setHasShadow method', function() { it('can be changed with setHasShadow method', function() {
if (process.platform != 'darwin')
return;
assert.equal(w.hasShadow(), true); assert.equal(w.hasShadow(), true);
w.setHasShadow(false); w.setHasShadow(false);
assert.equal(w.hasShadow(), false); assert.equal(w.hasShadow(), false);