Skip to content

Commit

Permalink
Merge 7ff4d3b into 3dae6a0
Browse files Browse the repository at this point in the history
  • Loading branch information
shundhammer committed May 4, 2022
2 parents 3dae6a0 + 7ff4d3b commit 7253f25
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 18 deletions.
72 changes: 56 additions & 16 deletions library/packages/src/modules/SlideShow.rb
Expand Up @@ -100,16 +100,12 @@
# - release notes viewer
require "yast"
require "yast2/system_time"
require "y2packager/product_spec"

module Yast
class SlideShowClass < Module
include Yast::Logger

module UI_ID
TOTAL_PROGRESS = :progressTotal
CURRENT_PACKAGE = :progressCurrentPackage
end

def main
Yast.import "UI"

Expand Down Expand Up @@ -158,18 +154,21 @@ def GetUserAbort

# Start the internal (global) timer.
#
# FIXME: Obsolete published method
def StartTimer
nil
end

# Reset the internal (global) timer.
#
# FIXME: Obsolete published method
def ResetTimer
nil
end

# Stop the internal (global) timer and account elapsed time.
#
# FIXME: Obsolete published method
def StopTimer
nil
end
Expand All @@ -184,6 +183,7 @@ def ShowingDetails
# Check if currently the "Slide Show" page is shown
# @return true if showing details, false otherwise
#
# FIXME: Obsolete published method
def ShowingSlide
false
end
Expand All @@ -202,6 +202,8 @@ def ProductRelNotesID(product)
# Restart the subprogress of the slideshow. This means the
# label will be set to given text, value to 0.
# @param [String] text new label for the subprogress
#
# FIXME: Obsolete published method
def SubProgressStart(text); end

# Updates status of the sub-progress in slide show. The new value and label
Expand All @@ -210,12 +212,16 @@ def SubProgressStart(text); end
#
# @param [Fixnum] value new value for the subprogress
# @param [String] label new label for the subprogress
#
# FIXME: Obsolete published method
def SubProgress(value, label); end

# Restart the global progress of the slideshow. This means the
# label will be set to given text, value to 0.
#
# @param [String] text new label for the global progress
#
# FIXME: Obsolete published method
def GlobalProgressStart(text)
UpdateGlobalProgress(0, text)
end
Expand All @@ -230,15 +236,15 @@ def UpdateGlobalProgress(value, label)
value ||= @total_progress_value
label ||= @total_progress_label

if UI.WidgetExists(UI_ID::TOTAL_PROGRESS)
if UI.WidgetExists(:progressTotal)
if @total_progress_value != value
@total_progress_value = value
UI.ChangeWidget(UI_ID::TOTAL_PROGRESS, :Value, value)
UI.ChangeWidget(:progressTotal, :Value, value)
end

if @total_progress_label != label
@total_progress_label = label
UI.ChangeWidget(UI_ID::TOTAL_PROGRESS, :Label, label)
UI.ChangeWidget(:progressTotal, :Label, label)
end
else
log.warn "progressTotal widget missing"
Expand Down Expand Up @@ -329,13 +335,15 @@ def HaveSlideWidget
# Check if the slide show is available. This must be called before trying
# to access any slides; some late initialization is done here.
#
# FIXME: Obsolete
def CheckForSlides
nil
end

# Set the slide show text.
# @param [String] text
#
# FIXME: Obsolete
def SetSlideText(_text)
nil
end
Expand All @@ -351,45 +359,74 @@ def SetLanguage(new_language)

# Create one single item for the CD statistics table
#
# FIXME: Obsolete published method
def TableItem(id, col1, col2, col3, col4)
Item(Id(id), col1, col2, col3, col4)
end

# Load a slide image + text.
# @param [Fixnum] slide_no number of slide to load
#
# FIXME: Obsolete
def LoadSlide(_slide_no)
nil
end

# Check if the current slide needs to be changed and do that if
# necessary.
#
# FIXME: Obsolete
def ChangeSlideIfNecessary
nil
end

# widgets for progress bar
# @return A term describing the widgets
# Widgets for the progress bar tab
# @return A term describing the widgets
#
def progress_widgets
HBox(
Id(:progress_bar),
HSpacing(1),
MarginBox(
4, 1, # hor/vert
VBox(
product_name_widgets,
VCenter(
ProgressBar(
Id(UI_ID::TOTAL_PROGRESS),
Id(:progressTotal),
@total_progress_label,
100,
@total_progress_value
)
)
),
HSpacing(0.5)
)
)
end

# Widgets for the product name
# @return A term describing the widgets
def product_name_widgets
text = product_name
return Empty() if text.nil? || text.empty?

MarginBox(
0, 1, # hor/vert
Left(
Label(Id(:productName), text)
)
)
end

# Name of the base product that is or will be installed
# @return [String,nil] Display name of the base product
def product_name
# Avoid expensive operation in the installed system where this will
# always return 'nil' anyway.
return nil if Mode.normal

product = Y2Packager::ProductSpec.selected_base
return nil if product.nil?

product.display_name
end

# Construct widgets describing a page with the real slide show
# (the RichText / HTML page)
#
Expand All @@ -413,6 +450,7 @@ def RelNotesPageWidgets(id); end

# Switch from the 'details' view to the 'slide show' view.
#
# FIXME: Obsolete
def SwitchToSlideView
return if ShowingSlide()

Expand All @@ -426,12 +464,14 @@ def SwitchToSlideView
end

# Rebuild the details page.
# FIXME: Obsolete
def RebuildDetailsView
nil
end

# Switch from the 'slide show' view to the 'details' view.
#
# FIXME: Obsolete
def SwitchToDetailsView
nil
end
Expand Down
22 changes: 21 additions & 1 deletion library/packages/test/slide_show_test.rb
Expand Up @@ -6,13 +6,33 @@
Yast.import "Slides"
Yast.import "UI"

# Avoid testing product_name() and the methods that are using it:
# This will break because we needed to suppress
#
# require "y2packager/product_spec"
#
# by overloading Kernel::require in ./test_helper.rb to avoid a cyclic
# dependency between this package and yast2-packager.
#
# It will work when running the unit tests locally, but it will break in an
# autobuild environment ("rake osc:build", "rake osc:sr") which is called in
# Jenkins because unlike any real-life system using YaST, an AutoBuild
# environment will NOT install yast2-packager anyway to satisfy other
# requirements. So this problem is hard to spot.
#
# It might be possible to force it to work with some heavy monkey-patching and
# instance_double, but for the extent of useful testing that it might bring,
# this is simply not worthwhile.
#
# 2022-05-04 shundhammer
#
describe "Yast::SlideShow" do
before(:each) do
Yast.y2milestone "--------- Running test ---------"
allow(::File).to receive(:exist?).and_return(true)
end

TOTAL_PROGRESS_ID = Yast::SlideShowClass::UI_ID::TOTAL_PROGRESS
TOTAL_PROGRESS_ID = :progressTotal

describe "#UpdateGlobalProgress" do
before(:each) do
Expand Down
26 changes: 26 additions & 0 deletions library/packages/test/test_helper.rb
Expand Up @@ -2,3 +2,29 @@
require "pathname"

PACKAGES_FIXTURES_PATH = Pathname.new(File.dirname(__FILE__)).join("data")

LIBS_TO_SKIP = [
"y2packager/product_spec" # used in SlideShow.rb
].freeze

# Hack to avoid to require some files. Stolen from
# https://github.com/yast/yast-storage-ng/blob/master/test/spec_helper.rb#L32-L50
#
# This is here to avoid a cyclic dependency with yast2-packager at build time.
# yast2.spec does build-require yast2-packager, so the (Ruby) require for files
# defined by that package must be avoided.
#
# Of course that means that tests might need to use instance() or
# instance_double() to make the missing classes and methods from those
# libraries available.
#
# Notice that the problem might be hidden for locally running the unit tests,
# but not when calling them in an Autobuild environment (e.g. "rake osc:build"
# or "rake osc:sr").
module Kernel
alias_method :old_require, :require

def require(path)
old_require(path) unless LIBS_TO_SKIP.include?(path)
end
end
6 changes: 6 additions & 0 deletions package/yast2.changes
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Tue May 3 14:05:10 UTC 2022 - Stefan Hundhammer <shundhammer@suse.com>

- Show what product is being installed (bsc#1196674)
- 4.5.2

-------------------------------------------------------------------
Thu Apr 7 11:43:15 UTC 2022 - Stefan Hundhammer <shundhammer@suse.com>

Expand Down
12 changes: 11 additions & 1 deletion package/yast2.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2
Version: 4.5.1
Version: 4.5.2

Release: 0
Summary: YaST2 Main Package
Expand Down Expand Up @@ -64,6 +64,16 @@ BuildRequires: yast2-ycp-ui-bindings >= 4.3.3
BuildRequires: cpio
BuildRequires: rpm

# Intentionally NOT requiring or build-requiring yast2-packager
# to avoid a cyclic dependency.
#
# For the BuildRequires, see test_helper.rb and slide_show_test.rb
# in library/packages/test/ .
#
# For the runtime Requires, it can safely be assumed that every system that
# does any package installation has yast2-packager from the dependencies of the
# client module that does that.

# for ag_tty (/bin/stty)
# for /usr/bin/md5sum
Requires: coreutils
Expand Down

0 comments on commit 7253f25

Please sign in to comment.