Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #48 from bjanzen/TestUp-bugfix-2013

Fixes TestUp tests for SketchUp 2013
  • Loading branch information...
commit 291603c517265bd90f5830e741b79778e404d1d6 2 parents 6947593 + 792199f
@thomthom thomthom authored
View
70 src/sketchup-developer-tools/testup/tests/bugs_fixed/TC_2119710.rb
@@ -1,70 +0,0 @@
-#!/usr/bin/ruby
-#
-# Copyright:: Copyright 2012 Trimble Navigation Ltd.
-# License:: Apache License version 2.0
-# Original Author:: Matt Lowrie
-#
-# Regression test for Buganizer Bug #2119710
-#
-
-require 'test/unit'
-
-# this can only be required on PC
-
-if not RUBY_PLATFORM.include? 'darwin'
- require 'platformhelper'
- require 'win32/apidefs'
- puts 'we are on windows'
-end
-
-class TC_2119710 < Test::Unit::TestCase
-
- def setup
- if RUBY_PLATFORM.include? 'darwin'
- raise('WARNING: this test case currently can run only on PC')
- end
- begin
- # Set the SketchUp window to a specific size to set the pick aperture.
- @platform_helper = PlatformHelper.new
- @is_win = RUBY_PLATFORM =~ /mswin/
- su_handle = @platform_helper.get_window_handle('SketchUp', 'SketchUp')
- gl_window_class = @is_win ? 'AfxFrameOrView' : nil
- @platform_helper.resize_window(su_handle, 500, 500, gl_window_class)
- rescue
- raise('WARNING: this test (TC_2119710) can only be run if the main ' +
- 'SketchUp window is NOT maximized. Please unmaximize your window ' +
- 'and try again.');
- end
-
- end
-
- def test_2119710
- m = Sketchup.active_model
- v = m.active_view
- s = m.selection
- s.clear
- ents = m.entities
- ents.clear!
-
- Sketchup.send_action('selectSelectionTool:')
-
- # Add long, skinny face
- ents.add_face([-150, 1, 0], [150, 1, 0], [150, -1, 0], [-150, -1, 0])
-
- c = Sketchup::Camera.new([50, 50, 20], [0, 0, 0], [0, 0, 1])
- c.perspective = true
- v.camera = c
- v.refresh
-
- ph = v.pick_helper
- ph.do_pick(v.center.x, v.center.y)
- # Show the selected entities to the user
- s.add ph.all_picked
-
- # A DrawingElement and a Face get picked with this operation.
- assert_equal(2, ph.all_picked.length,
- 'Unexpected number of entities picked.')
- assert(ph.picked_face, 'A face should have been picked, but was not.')
- assert_nil(ph.picked_edge, 'An edge was picked, but should not have been.')
- end
-end
View
217 src/sketchup-developer-tools/testup/tests/functional_tests/TC_Picking.rb
@@ -1,217 +0,0 @@
-#!/usr/bin/ruby
-#
-# Copyright:: Copyright 2012 Trimble Navigation Ltd.
-# License:: Apache License version 2.0
-# Original Author:: Matt Lowrie
-#
-# Functional picking tests for SketchUp.
-#
-# $Id: //depot/eng/doc/rubyguide.html#35 $
-
-require 'test/unit'
-require 'platformhelper' unless RUBY_PLATFORM.include? 'darwin'
-
-# In case we are on Mac we do not want to define a class relying
-# on the Windows only PLatformHelper, we instead define a class
-# that has a single method displaying an error clearly stating that
-# we can only run these tests on Windows.
-if RUBY_PLATFORM.include? 'darwin'
- class TC_Picking < Test::Unit::TestCase
-
- def test_mac
- raise('Wrong Platform - this test can only run on Windows')
- end
-
- end
-
-else
-
- class TC_Picking < Test::Unit::TestCase
-
- # Override the TestCase class initializer.
- #
- # Resizing the window is expensive, so we only want to do it once in the
- # class initializer.
- #
- def initialize arg
- super arg
- # Platform helper to manipulate the SketchUp application window
- @platform_helper = PlatformHelper.new
- # To accurately test pick rays, we need to have a known view area size
- @test_resize_dimension = 500
- su_window = @platform_helper.get_window_handle('SketchUp', 'SketchUp')
- @platform_helper.resize_window(su_window,
- @test_resize_dimension,
- @test_resize_dimension,
- 'AfxFrameOrView')
- end
-
-
- def setup
- # Check that the view has not resized between each test
- viewport_width = Sketchup.active_model.active_view.vpwidth
- viewport_height = Sketchup.active_model.active_view.vpheight
- assert_equal(@test_resize_dimension, viewport_width,
- 'The SketchUp window did not resize correctly.' +
- 'Aborting test.')
- assert_equal(@test_resize_dimension, viewport_height,
- 'The SketchUp window did not resize correctly.' +
- 'Aborting test.')
-
- # Clean up the model
- m = Sketchup.active_model
- @v = m.active_view
- @s = m.selection
- @s.clear
- @ents = m.entities
- @ents.clear!
-
- # Draw an array of faces as our test entities... 10 unit faces with 2 units
- # spacing between
- (-29..19).step(12) do |x|
- (-29..19).step(12) do |y|
- pts = [x, y, 0], [x + 10, y, 0], [x + 10, y + 10, 0], [x, y + 10, 0]
- @ents.add_face(pts)
- end
- end
- end
-
- def test_perspective_center_pick_at_10_units
- # A camera at 100 units
- test_cam = Sketchup::Camera.new([10, 10, 10], [0, 0, 0], [0, 0, 1])
- test_cam.perspective = true
- @v.camera = test_cam
- @v.refresh
-
- mid = @test_resize_dimension / 2
- test_pick_helper = @v.pick_helper
- test_pick_helper.do_pick(mid, mid)
- # Show the selection for fun
- @s.add(test_pick_helper.all_picked)
- # Picking is non-deterministic. Sometimes this pick catches a Drawing
- # Element entity, so the length can be 1 or 2.
- assert_equal(2, test_pick_helper.count,
- 'Camera at 10-units did not pick expected number of entities')
- end
-
- def test_perspective_center_pick_at_100_units
- # A camera at 100 units
- test_cam = Sketchup::Camera.new([100, 100, 100], [0, 0, 0], [0, 0, 1])
- test_cam.perspective = true
- @v.camera = test_cam
- @v.refresh
-
- mid = @test_resize_dimension / 2
- test_pick_helper = @v.pick_helper
- test_pick_helper.do_pick(mid, mid)
- # Show the selection for fun
- @s.clear
- @s.add(test_pick_helper.all_picked)
- assert_equal(2, test_pick_helper.count,
- 'Camera at 100-units did not pick expected number of entities')
- end
-
- def test_perspective_center_pick_at_1000_units
- # A camera at 1000 units
- test_cam = Sketchup::Camera.new([1000, 1000, 1000], [0, 0, 0], [0, 0, 1])
- test_cam.perspective = true
- @v.camera = test_cam
- @v.refresh
-
- mid = @test_resize_dimension / 2
- test_pick_helper = @v.pick_helper
- test_pick_helper.do_pick(mid, mid)
- # Show the selection for fun
- @s.clear
- @s.add(test_pick_helper.all_picked)
- assert_equal(6, test_pick_helper.count,
- "Camera at 1000-units didn't pick expected number of entities")
- end
-
- def test_perspective_center_pick_at_5000_units
- # A camera at 5000 units
- test_cam = Sketchup::Camera.new([5000, 5000, 5000], [0, 0, 0], [0, 0, 1])
- test_cam.perspective = true
- @v.camera = test_cam
- @v.refresh
-
- mid = @test_resize_dimension / 2
- test_pick_helper = @v.pick_helper
- test_pick_helper.do_pick(mid, mid)
- # Show the selection for fun
- @s.clear
- @s.add(test_pick_helper.all_picked)
- assert_equal(48, test_pick_helper.count,
- "Camera at 5000-units didn't pick expected number of entities")
- end
-
- def test_orthographic_center_pick_at_10_units
- # A camera at 10 units
- test_cam = Sketchup::Camera.new([10, 10, 10], [0, 0, 0], [0, 0, 1])
- test_cam.perspective = false
- @v.camera = test_cam
- @v.refresh
-
- mid = @test_resize_dimension / 2
- test_pick_helper = @v.pick_helper
- test_pick_helper.do_pick(mid, mid)
- # Show the selection for fun
- @s.add(test_pick_helper.all_picked)
- # Picking is non-deterministic. Sometimes this pick catches a Drawing
- # Element entity, so the length can be 1 or 2.
- assert_equal(2, test_pick_helper.count,
- 'Camera at 10-units did not pick expected number of entities')
- end
-
- def test_orthographic_center_pick_at_100_units
- # A camera at 100 units
- test_cam = Sketchup::Camera.new([100, 100, 100], [0, 0, 0], [0, 0, 1])
- test_cam.perspective = false
- @v.camera = test_cam
- @v.refresh
-
- mid = @test_resize_dimension / 2
- test_pick_helper = @v.pick_helper
- test_pick_helper.do_pick(mid, mid)
- # Show the selection for fun
- @s.clear
- @s.add(test_pick_helper.all_picked)
- assert_equal(2, test_pick_helper.count,
- 'Camera at 100-units did not pick expected number of entities')
- end
-
- def test_orthographic_center_pick_at_1000_units
- # A camera at 1000 units
- test_cam = Sketchup::Camera.new([1000, 1000, 1000], [0, 0, 0], [0, 0, 1])
- test_cam.perspective = false
- @v.camera = test_cam
- @v.refresh
-
- mid = @test_resize_dimension / 2
- test_pick_helper = @v.pick_helper
- test_pick_helper.do_pick(mid, mid)
- # Show the selection for fun
- @s.clear
- @s.add(test_pick_helper.all_picked)
- assert_equal(6, test_pick_helper.count,
- "Camera at 1000-units didn't pick expected number of entities")
- end
-
- def test_orthographic_center_pick_at_5000_units
- # Now a camera at 1000 units
- test_cam = Sketchup::Camera.new([5000, 5000, 5000], [0, 0, 0], [0, 0, 1])
- test_cam.perspective = false
- @v.camera = test_cam
- @v.refresh
-
- mid = @test_resize_dimension / 2
- test_pick_helper = @v.pick_helper
- test_pick_helper.do_pick(mid, mid)
- # Show the selection for fun
- @s.clear
- @s.add(test_pick_helper.all_picked)
- assert_equal(48, test_pick_helper.count,
- "Camera at 5000-units didn't pick expected number of entities")
- end
- end
-end
View
139 src/sketchup-developer-tools/testup/tests/functional_tests/TC_importers_sanity.rb
@@ -214,98 +214,36 @@ def set_win_options
def set_mac_options
# Set correct plist name depending on which version of SU is being run.
- # Note: until http://b/issue?id=2439148 is fixed, the plist name will be
- # wrong when running SU Free.
- plist_name = 'com.google.sketchuppro'
- plist_name = 'com.google.sketchupfree' if @model.get_product_family == 1
-
- # For each importer, create a hash containing the key names and key values
- # associated with each importer option
- importer_settings = Hash.new()
- importer_settings['3ds'] = {
- 'SketchUp.Preferences.Import3DS.Units' => 1,
- 'SketchUp.Preferences.Import3DS.MergeCoplanar' => 0,
- 'SketchUp.Preferences.Import3DS.SoftEdges' => 0}
- importer_settings['dwg'] = {
- 'SketchUp.Preferences.ImportMergeFaces' => 0,
- 'SketchUp.Preferences.ImportOrientFaces' => 1,
- 'SketchUp.Preferences.ImportDwgUnits' => 1,
- 'SketchUp.Preferences.DwgImportPreserveOrigin' => 0}
- importer_settings['dae'] = {
- 'com.google.sketchup.import.dae.ImportMergeCoplanarFaces' => 0,
- 'com.google.sketchup.import.dae.ImportValidateDAE' => 1}
- importer_settings['dem'] = {
- 'SketchUp.Preferences.ExportDEM.MaxError' =>10,
- 'SketchUp.Preferences.ExportDEM.GenTexture' => 0,
- 'SketchUp.Preferences.ExportDEM.HeightScale' => 1,
- 'SketchUp.Preferences.ExportDEM.MaxPoints' => 250}
-
- # Set the name of a temp file we will use in the next loop
- temp_file = "#{@supporting_data_dir}/temp_key_file"
-
- # Initialize a counter we will use in the next loop
- nr_different_keys = 0
-
- # Loop through the array of importers that need options to be set
- @arr_of_importers_with_options.each do |importer_extension|
-
- # Loop through the hash containing the importer specific key names and
- # key values
- importer_settings[importer_extension].each do |key, value|
-
- # Determine if the current value in the plist is different than the
- # value we want to set. If they are different, we will need to
- # prompt the user to close/reopen SU. The following code
- # will immediately write our new values to the plist. SU's
- # importers though, don't register that new values have been
- # set until we close/reopen the app. If we don't do this step,
- # our test could give a false negative.
-
- # Create a variable to hold the current plist key value
- current_key_value = nil
-
- # Compose a string that, when passed to the system, will read the
- # current key value and pipe the output to our temp file. If we don't
- # create a temp file, the defaults read command would simply
- # return true or false vs giving us the key value.
- read_command="defaults read #{plist_name}#{@su_version} " +
- "#{key} > '#{temp_file}'"
-
- # Pass the command string to the system to create the temp file
- system(read_command)
-
- # Set our current key value by opening the temp file and reading
- # the first line
- f = File.open temp_file
- first_line = f.readlines[0]
- current_key_value = first_line.chomp if first_line != nil
- f.close
-
- # Compare the current key value to the value we want to set. If they
- # are different, increment a counter which keeps track of the number
- # of keys that are different.
- if current_key_value.to_s != value.to_s
- nr_different_keys += 1
- end
-
- # Compose a string that, when passed to the system, will write to the
- # plist, the key values we want to set.
- write_command = "defaults write #{plist_name}#{@su_version} " +
- "#{key} #{value}"
-
- # Pass the command to the system to write our new values to the plist
- system(write_command)
- end
+ # Note: fixed for 2013. Changes required a rewrite of this function.
+ plist_name = 'defaults write com.sketchup.SketchUp '
+
+ # Prefs changed so that all 4 for DWG are in com.sketchup.SketchUp
+ # Preferences. In order to not write out the entire dictionary, we'll do a
+ # defaults write com.sketchup.SketchUp Preferences -dict-add, and
+ # we can do this all in one call, eliminating a need for hash.
+ importer_settings = Array.new()
+ importer_settings.push(%Q!"3DS Importer"! + ' -dict-add FileUnits 1' +
+ ' MergeCoplanar 0 SoftEdges 0')
+ importer_settings.push("Preferences -dict-add ImportMergeFaces 0" +
+ ' ImportOrientFaces 1 ImportDwgUnits 1 DwgImportPreserveOrigin 0')
+ importer_settings.push(%Q!"Dae Importer"! + ' -dict-add ' +
+ 'ImportMergeCoplanarFaces 0 ImportValidateDAE 1')
+ importer_settings.push(%Q!"DEM Importer"! + ' -dict-add ' +
+ 'GenTexture 0 MaxPoints 250')
+
+ importer_settings.each do |defaults|
+ system(plist_name + defaults)
end
# If we found we needed to make changes to any of the importer options,
# raise an error prompting the user to exit and relaunch SU.
- if nr_different_keys > 0
- raise RuntimeError, "\n TestUp needed to set some import preferences
- that were different than what you had previously. For them
- to take effect, you need to exit SU and then rerun this
- test. \n"
- end
+ # Todo(bjanzen) - do the read and notify user that a restart is necessary.
+ #if nr_different_keys > 0
+ # raise RuntimeError, "\n TestUp needed to set some import preferences
+ # that were different than what you had previously. For them
+ # to take effect, you need to exit SU and then rerun this
+ # test. \n"
+ #end
end
@@ -423,7 +361,7 @@ def drill_down_hierarchy(arr_of_entities)
# Method to import a file
# The method includes logic for doing additional steps for the 3ds and skp
- # importers
+ # importers. (dae as well due to a bug introduced in SketchUp 2013)
#
# Args:
# filename: name of file to be imported
@@ -437,15 +375,15 @@ def import_file(filename, filename_extension)
Sketchup.active_model.import(filename.to_s, false)
# This is a hack to make 3ds/skp import work. The problem is that the 3ds
- # and skp importers don't place the geometry in the model when imported.
- # Instead, they import the geometry as a component that needs to be
- # placed and until it is placed, no geometry shows up in the model. This
- # code finds the top most definition based on expected name and inserts it
- # into the model. Note: for 3ds,this code only needs to be executed on Win
- # as the Mac behaves differently, directly inserting the 3ds file.
- #
- # TODO(tricias): look for a better way to do this
- if filename_extension == '3ds' and @platform == 'win'
+ # and skp (and with SketchUp 2013, dae) importers don't place the geometry
+ # in the model when imported. Instead, they import the geometry as a
+ # component that needs to be placed and until it is placed, no geometry shows
+ # up in the model. This code finds the top most definition based on expected
+ # name and inserts it into the model. Note: for 3ds, this code only needs to
+ # be executed on Win as the Mac behaves differently, directly inserting the
+ # 3ds file.
+ # TODO: look for a better way to do this
+ if filename_extension == '3ds' # this is now Mac, too, in 2013: and @platform == 'win'
@defs.each do |item|
# Find the top most definition which, for 3ds, has "skp" in the name
@@ -474,6 +412,11 @@ def import_file(filename, filename_extension)
end
end
end
+ if filename_extension == 'dae'
+ point = Geom::Point3d.new 10,20,30
+ transform = Geom::Transformation.new point
+ instance = @entities.add_instance @defs[0], transform
+ end
end
View
3  src/sketchup-developer-tools/testup/tests/functional_tests/TC_install_from_rbz.rb
@@ -16,7 +16,8 @@ class TC_install_from_rbz < Test::Unit::TestCase
def setup
@supporting_data_dir = __FILE__.slice(0, __FILE__.rindex('.'))
- @examples_path = Sketchup.find_support_file('examples.rb', 'plugins')
+ # examples.rb is no longer installed by default. Use su_webtextures.
+ @examples_path = Sketchup.find_support_file('su_webtextures.rb', 'plugins')
@plugins_dir = @examples_path.slice(0, @examples_path.rindex('/'))
end
View
117 src/sketchup-developer-tools/testup/tests/ruby_classes/TC_Image.rb
@@ -46,7 +46,18 @@ def UI::messagebox(params)
end
end
+ def set_image(image_name)
+ model = Sketchup.active_model
+ path = Sketchup.find_support_file image_name, "Plugins" +
+ "/su_dynamiccomponents/images"
+ pt = Geom::Point3d.new
+ entities = model.active_entities
+ return (entities.add_image path, pt, 300)
+ end
+
+
# ----------------------------------------------------------------------------
+ #
# @par Ruby Method: Image.width
# @file rimage.cpp
#
@@ -64,12 +75,7 @@ def UI::messagebox(params)
# Test the example code that we have in the API documentation.
def test_width_api_example
assert_nothing_raised do
- model = Sketchup.active_model
- path = Sketchup.find_support_file "report_tool.png",
- "Tools/DynamicComponents/images"
- pt = Geom::Point3d.new
- entities = model.active_entities
- image = entities.add_image path, pt, 300
+ image = set_image "report_tool.png"
width = image.width
if (width)
UI.messagebox width
@@ -113,11 +119,7 @@ def test_width_api_example
# Test the example code that we have in the API documentation.
def test_set_size_api_example
assert_nothing_raised do
- model = Sketchup.active_model
- path = Sketchup.find_support_file "report_tool.png", "Tools/DynamicComponents/images"
- pt = Geom::Point3d.new
- entities = model.active_entities
- image = entities.add_image path, pt, 300
+ image = set_image "report_tool.png"
UI.messagebox "Before Resize"
size = image.size= 500,500
if (size)
@@ -161,11 +163,7 @@ def test_set_size_api_example
# Test the example code that we have in the API documentation.
def test_explode_api_example
assert_nothing_raised do
- model = Sketchup.active_model
- path = Sketchup.find_support_file "report_tool.png", "Tools/DynamicComponents/images"
- pt = Geom::Point3d.new
- entities = model.active_entities
- image = entities.add_image path, pt, 300
+ image = set_image "report_tool.png"
entitiesarray = image.explode
if (entitiesarray)
UI.messagebox entitiesarray
@@ -207,13 +205,9 @@ def test_explode_api_example
# Test the example code that we have in the API documentation.
def test_transform_api_example
assert_nothing_raised do
- model = Sketchup.active_model
- path = Sketchup.find_support_file "report_tool.png", "Tools/DynamicComponents/images"
+ image = set_image "report_tool.png"
point = Geom::Point3d.new 100,100,100
t = Geom::Transformation.new point
- pt = Geom::Point3d.new
- entities = model.active_entities
- image = entities.add_image path, pt, 300
UI.messagebox "Before Move"
image = image.transform! t
if (image)
@@ -258,11 +252,7 @@ def test_transform_api_example
# Test the example code that we have in the API documentation.
def test_set_height_api_example
assert_nothing_raised do
- model = Sketchup.active_model
- path = Sketchup.find_support_file "report_tool.png", "Tools/DynamicComponents/images"
- pt = Geom::Point3d.new
- entities = model.active_entities
- image = entities.add_image path, pt, 300
+ image = set_image "report_tool.png"
UI.messagebox "Before adjustment"
height = image.height = 400
if (height)
@@ -307,11 +297,7 @@ def test_set_height_api_example
# Test the example code that we have in the API documentation.
def test_set_width_api_example
assert_nothing_raised do
- model = Sketchup.active_model
- path = Sketchup.find_support_file "report_tool.png", "Tools/DynamicComponents/images"
- pt = Geom::Point3d.new
- entities = model.active_entities
- image = entities.add_image path, pt, 300
+ image = set_image "report_tool.png"
UI.messagebox "Before adjustment"
width = image.width=400
if (width)
@@ -354,11 +340,7 @@ def test_set_width_api_example
# Test the example code that we have in the API documentation.
def test_normal_api_example
assert_nothing_raised do
- model = Sketchup.active_model
- path = Sketchup.find_support_file "report_tool.png", "Tools/DynamicComponents/images"
- pt = Geom::Point3d.new
- entities = model.active_entities
- image = entities.add_image path, pt, 300
+ image = set_image "report_tool.png"
vector = image.normal
if (vector)
UI.messagebox vector
@@ -402,12 +384,8 @@ def test_normal_api_example
# Test the example code that we have in the API documentation.
def test_set_origin_api_example
assert_nothing_raised do
- model = Sketchup.active_model
- path = Sketchup.find_support_file "report_tool.png", "Tools/DynamicComponents/images"
- pt = Geom::Point3d.new
+ image= set_image "report_tool.png"
pt2 = Geom::Point3d.new 100,100,100
- entities = model.active_entities
- image = entities.add_image path, pt, 300
UI.messagebox "Before Move"
origin = image.origin=pt2
if (origin)
@@ -451,11 +429,7 @@ def test_set_origin_api_example
# Test the example code that we have in the API documentation.
def test_height_api_example
assert_nothing_raised do
- model = Sketchup.active_model
- path = Sketchup.find_support_file "report_tool.png", "Tools/DynamicComponents/images"
- pt = Geom::Point3d.new
- entities = model.active_entities
- image = entities.add_image path, pt, 300
+ image = set_image "report_tool.png"
height = image.height
if (height)
UI.messagebox height
@@ -497,11 +471,7 @@ def test_height_api_example
# Test the example code that we have in the API documentation.
def test_zrotation_api_example
assert_nothing_raised do
- model = Sketchup.active_model
- path = Sketchup.find_support_file "report_tool.png", "Tools/DynamicComponents/images"
- pt = Geom::Point3d.new
- entities = model.active_entities
- image = entities.add_image path, pt, 300
+ image = set_image "report_tool.png"
zrotation = image.zrotation
if (zrotation)
UI.messagebox zrotation
@@ -543,11 +513,7 @@ def test_zrotation_api_example
# Test the example code that we have in the API documentation.
def test_path_api_example
assert_nothing_raised do
- model = Sketchup.active_model
- path = Sketchup.find_support_file "report_tool.png", "Tools/DynamicComponents/images"
- pt = Geom::Point3d.new
- entities = model.active_entities
- image = entities.add_image path, pt, 300
+ image = set_image "report_tool.png"
path = image.path
if (path)
UI.messagebox path
@@ -590,11 +556,7 @@ def test_path_api_example
# Test the example code that we have in the API documentation.
def test_origin_api_example
assert_nothing_raised do
- model = Sketchup.active_model
- path = Sketchup.find_support_file "report_tool.png", "Tools/DynamicComponents/images"
- pt = Geom::Point3d.new
- entities = model.active_entities
- image = entities.add_image path, pt, 300
+ image = set_image "report_tool.png"
origin = image.origin
if (origin)
UI.messagebox origin
@@ -637,11 +599,7 @@ def test_origin_api_example
# Test the example code that we have in the API documentation.
def test_pixelheight_api_example
assert_nothing_raised do
- model = Sketchup.active_model
- path = Sketchup.find_support_file "report_tool.png", "Tools/DynamicComponents/images"
- pt = Geom::Point3d.new
- entities = model.active_entities
- image = entities.add_image path, pt, 300
+ image = set_image "report_tool.png"
pixelheight = image.pixelheight
if (pixelheight)
UI.messagebox pixelheight
@@ -683,11 +641,7 @@ def test_pixelheight_api_example
# Test the example code that we have in the API documentation.
def test_pixelwidth_api_example
assert_nothing_raised do
- model = Sketchup.active_model
- path = Sketchup.find_support_file "report_tool.png", "Tools/DynamicComponents/images"
- pt = Geom::Point3d.new
- entities = model.active_entities
- image = entities.add_image path, pt, 300
+ image = set_image "report_tool.png"
pixelwidth = image.pixelwidth
if (pixelwidth)
UI.messagebox pixelwidth
@@ -729,14 +683,9 @@ def test_pixelwidth_api_example
# Test the example code that we have in the API documentation.
def test_transform_inplace_api_example
assert_nothing_raised do
- model = Sketchup.active_model
- path = Sketchup.find_support_file "report_tool.png",
- "Tools/DynamicComponents/images"
+ image = set_image "report_tool.png"
point = Geom::Point3d.new 100,100,100
t = Geom::Transformation.new point
- pt = Geom::Point3d.new
- entities = model.active_entities
- image = entities.add_image path, pt, 300
UI.messagebox "Before Move"
image = image.transform! t
if (image)
@@ -748,26 +697,16 @@ def test_transform_inplace_api_example
end
def test_transform_inplace_edgecases
- model = Sketchup.active_model
- path = Sketchup.find_support_file "report_tool.png",
- "Tools/DynamicComponents/images"
+ image = set_image "report_tool.png"
point = Geom::Point3d.new 0,0,0
t = Geom::Transformation.new point
- pt = Geom::Point3d.new
- entities = model.active_entities
- image = entities.add_image path, pt, 300
UI.messagebox "Before Move"
image = image.transform! t
assert_not_nil(image)
end
def test_transform_inplace_bad_params
- model = Sketchup.active_model
- path = Sketchup.find_support_file "report_tool.png",
- "Tools/DynamicComponents/images"
- pt = Geom::Point3d.new
- entities = model.active_entities
- image = entities.add_image path, pt, 300
+ image = set_image "report_tool.png"
UI.messagebox "Before Move"
assert_raise(TypeError) do
image = image.transform! "bad params"
View
30 src/sketchup-developer-tools/testup/tests/ruby_classes/TC_SketchupExtension.rb
@@ -46,6 +46,9 @@ def setup
$testup_dc_extension_noload.creator = 'testup_creator_noload'
$testup_dc_extension_noload.copyright = 'testup_copyright_noload'
Sketchup.register_extension $testup_dc_extension_noload, false
+ su_examples = Sketchup.find_support_file('Plugins') + '/su_examples'
+ $test_su_examples_absent = !(File.directory? su_examples)
+
end
end
@@ -62,6 +65,12 @@ def teardown
$testup_dc_extension_noload.creator = 'testup_creator_noload';
end
+ def examples_not_installed(test_name)
+ return test_name + ' can only be run if Examples Extension is loaded ' +
+ 'from Extension Warehouse; search on Example Ruby Scripts by The ' +
+ 'SketchUp Team, and install'
+ end
+
def test_name
assert_equal('testup_name_autoload', $testup_dc_extension_autoload.name,
'testup_name_autoload')
@@ -164,6 +173,11 @@ def test_loaded?
end
def test_check
+ if $test_su_examples_absent == true
+ raise examples_not_installed('test_check')
+ return
+ end
+
if $test_load_has_run == true
raise('test_load can only be run once per SketchUp session.')
return
@@ -171,7 +185,7 @@ def test_check
# Create an extension and register it not to load on start.
my_extension = SketchupExtension.new('testup_will_load' + Time.new.to_s,
- 'Examples/animation.rb')
+ 'su_examples/animation.rb')
Sketchup.register_extension my_extension, false
@@ -195,6 +209,11 @@ def test_check
end
def test_register
+ if $test_su_examples_absent == true
+ raise examples_not_installed('test_register')
+ return
+ end
+
if $test_register_has_run == true
raise('test_register can only be run once per SketchUp session.')
return
@@ -205,7 +224,7 @@ def test_register
# always re-registers.
name = 'testup_to_register' + Time.new.to_s
reg_extension = SketchupExtension.new(name,
- 'Examples/box.rb')
+ 'su_examples/box.rb')
assert_equal(false, reg_extension.loaded?,
'reg_extension.loaded?')
@@ -254,12 +273,17 @@ def test_check_fail
end
def test_check_success
+ if $test_su_examples_absent == true
+ raise examples_not_installed('test_check_success')
+ return
+ end
+
if $test_load_success_has_run == true
raise('test_load_success can only be run once per SketchUp session.')
return
end
loadable_extension = SketchupExtension.new('loadable_extension',
- 'Examples/attributes.rb')
+ 'su_examples/attributes.rb')
result = loadable_extension.check;
Please sign in to comment.
Something went wrong with that request. Please try again.