From cc560a39008a8eb2b7645d00f4b20fded42edaf0 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 23 Jan 2016 20:03:56 +0800 Subject: [PATCH] spec: Fix failing tests on Windows --- atom/browser/native_window_views.cc | 10 ++++++++-- spec/api-browser-window-spec.js | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 910a0c782b60..44df87da9fb8 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -158,7 +158,7 @@ NativeWindowViews::NativeWindowViews( // The given window is most likely not rectangular since it uses // transparency and has no standard frame, don't show a shadow for it. 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) params.native_widget = @@ -441,7 +441,11 @@ void NativeWindowViews::SetResizable(bool resizable) { } bool NativeWindowViews::IsResizable() { +#if defined(OS_WIN) + return ::GetWindowLong(GetAcceleratedWidget(), GWL_STYLE) & WS_THICKFRAME; +#else return CanResize(); +#endif } void NativeWindowViews::SetMovable(bool movable) { @@ -598,7 +602,9 @@ void NativeWindowViews::SetBackgroundColor(const std::string& color_name) { } 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() { diff --git a/spec/api-browser-window-spec.js b/spec/api-browser-window-spec.js index 3c98e7a42f9d..fc8d3523c8fb 100644 --- a/spec/api-browser-window-spec.js +++ b/spec/api-browser-window-spec.js @@ -597,13 +597,19 @@ describe('browser-window module', 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() { w.destroy(); - w = new BrowserWindow({show: false, hasShadow: false}); - assert.equal(w.hasShadow(), false); + let hasShadow = process.platform == 'darwin' ? false : true; + w = new BrowserWindow({show: false, hasShadow: hasShadow}); + assert.equal(w.hasShadow(), hasShadow); }); it('can be changed with setHasShadow method', function() { + if (process.platform != 'darwin') + return; + assert.equal(w.hasShadow(), true); w.setHasShadow(false); assert.equal(w.hasShadow(), false);