Skip to content

Commit 26d1234

Browse files
Merge pull request #2924 from Catrobat/hotfix-0.9.36
Hotfix 0.9.36
2 parents 9bd361e + 5ea1462 commit 26d1234

80 files changed

Lines changed: 570 additions & 553 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

catroid/build.gradle

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,9 @@ dependencies {
239239
androidTestCompile ('com.android.support.test.espresso:espresso-contrib:3.0.1') {
240240
exclude group: 'com.android.support'
241241
}
242+
androidTestCompile ('com.android.support.test.espresso:espresso-intents:3.0.1') {
243+
exclude group: 'com.android.support'
244+
}
242245

243246
compile ('com.android.support.test.espresso:espresso-core:3.0.1') {
244247
exclude group: 'com.android.support'
@@ -276,9 +279,9 @@ android {
276279
targetSdkVersion 22
277280
applicationId appId
278281
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
279-
versionCode 43
282+
versionCode 44
280283
println "VersionCode is " + versionCode
281-
versionName "0.9.34"
284+
versionName "0.9.36"
282285
println "VersionName is " + versionName
283286
buildConfigField "String", "GIT_DESCRIBE", "\"${versionName}\""
284287
buildConfigField "String", "GIT_CURRENT_BRANCH", "\"${getCurrentGitBranch()}\""
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/*
2+
* Catroid: An on-device visual programming system for Android devices
3+
* Copyright (C) 2010-2018 The Catrobat Team
4+
* (<http://developer.catrobat.org/credits>)
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Affero General Public License as
8+
* published by the Free Software Foundation, either version 3 of the
9+
* License, or (at your option) any later version.
10+
*
11+
* An additional term exception under section 7 of the GNU Affero
12+
* General Public License, version 3, is available at
13+
* http://developer.catrobat.org/license_additional_term
14+
*
15+
* This program is distributed in the hope that it will be useful,
16+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
* GNU Affero General Public License for more details.
19+
*
20+
* You should have received a copy of the GNU Affero General Public License
21+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
22+
*/
23+
24+
package org.catrobat.catroid.uiespresso.content.brick.app;
25+
26+
import android.support.test.espresso.intent.Intents;
27+
import android.support.test.runner.AndroidJUnit4;
28+
29+
import org.catrobat.catroid.R;
30+
import org.catrobat.catroid.content.bricks.SetBackgroundBrick;
31+
import org.catrobat.catroid.ui.SpriteActivity;
32+
import org.catrobat.catroid.ui.WebViewActivity;
33+
import org.catrobat.catroid.uiespresso.content.brick.utils.BrickTestUtils;
34+
import org.catrobat.catroid.uiespresso.testsuites.Cat;
35+
import org.catrobat.catroid.uiespresso.testsuites.Level;
36+
import org.catrobat.catroid.uiespresso.util.rules.BaseActivityInstrumentationRule;
37+
import org.junit.Before;
38+
import org.junit.Rule;
39+
import org.junit.Test;
40+
import org.junit.experimental.categories.Category;
41+
import org.junit.runner.RunWith;
42+
43+
import static android.support.test.espresso.Espresso.onView;
44+
import static android.support.test.espresso.action.ViewActions.click;
45+
import static android.support.test.espresso.intent.Intents.intended;
46+
import static android.support.test.espresso.intent.matcher.BundleMatchers.hasEntry;
47+
import static android.support.test.espresso.intent.matcher.IntentMatchers.hasComponent;
48+
import static android.support.test.espresso.intent.matcher.IntentMatchers.hasExtras;
49+
import static android.support.test.espresso.matcher.ViewMatchers.withId;
50+
51+
import static org.catrobat.catroid.common.Constants.LIBRARY_BACKGROUNDS_URL_PORTRAIT;
52+
import static org.catrobat.catroid.uiespresso.content.brick.utils.BrickDataInteractionWrapper.onBrickAtPosition;
53+
import static org.hamcrest.Matchers.equalTo;
54+
import static org.hamcrest.core.AllOf.allOf;
55+
56+
@RunWith(AndroidJUnit4.class)
57+
public class SetBackgroundBrickTest {
58+
private int brickPosition;
59+
60+
@Rule
61+
public BaseActivityInstrumentationRule<SpriteActivity> baseActivityTestRule = new
62+
BaseActivityInstrumentationRule<>(SpriteActivity.class, SpriteActivity.EXTRA_FRAGMENT_POSITION, SpriteActivity.FRAGMENT_SCRIPTS);
63+
64+
@Before
65+
public void setUp() throws Exception {
66+
brickPosition = 1;
67+
BrickTestUtils.createProjectAndGetStartScript("SetBackgroundBrickTest")
68+
.addBrick(new SetBackgroundBrick());
69+
baseActivityTestRule.launchActivity();
70+
}
71+
72+
@Category({Cat.AppUi.class, Level.Smoke.class})
73+
@Test
74+
public void testSetBackgroundBrickMediaLibraryUrl() {
75+
onBrickAtPosition(0).checkShowsText(R.string.brick_when_started);
76+
onBrickAtPosition(brickPosition).checkShowsText(R.string.brick_set_background);
77+
78+
onBrickAtPosition(brickPosition).onSpinner(R.id.brick_set_look_spinner)
79+
.performSelect(R.string.brick_variable_spinner_create_new_variable);
80+
81+
Intents.init();
82+
83+
onView(withId(R.id.dialog_new_look_media_library))
84+
.perform(click());
85+
86+
intended(allOf(hasComponent(WebViewActivity.class.getName()),
87+
hasExtras(allOf(hasEntry(equalTo(WebViewActivity.INTENT_PARAMETER_URL),
88+
equalTo(LIBRARY_BACKGROUNDS_URL_PORTRAIT))))));
89+
90+
Intents.release();
91+
}
92+
}
93+
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/*
2+
* Catroid: An on-device visual programming system for Android devices
3+
* Copyright (C) 2010-2018 The Catrobat Team
4+
* (<http://developer.catrobat.org/credits>)
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Affero General Public License as
8+
* published by the Free Software Foundation, either version 3 of the
9+
* License, or (at your option) any later version.
10+
*
11+
* An additional term exception under section 7 of the GNU Affero
12+
* General Public License, version 3, is available at
13+
* http://developer.catrobat.org/license_additional_term
14+
*
15+
* This program is distributed in the hope that it will be useful,
16+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
* GNU Affero General Public License for more details.
19+
*
20+
* You should have received a copy of the GNU Affero General Public License
21+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
22+
*/
23+
24+
package org.catrobat.catroid.uiespresso.content.brick.app;
25+
26+
import android.support.test.espresso.intent.Intents;
27+
import android.support.test.runner.AndroidJUnit4;
28+
29+
import org.catrobat.catroid.R;
30+
import org.catrobat.catroid.content.bricks.SetLookBrick;
31+
import org.catrobat.catroid.ui.SpriteActivity;
32+
import org.catrobat.catroid.ui.WebViewActivity;
33+
import org.catrobat.catroid.uiespresso.content.brick.utils.BrickTestUtils;
34+
import org.catrobat.catroid.uiespresso.testsuites.Cat;
35+
import org.catrobat.catroid.uiespresso.testsuites.Level;
36+
import org.catrobat.catroid.uiespresso.util.rules.BaseActivityInstrumentationRule;
37+
import org.junit.Before;
38+
import org.junit.Rule;
39+
import org.junit.Test;
40+
import org.junit.experimental.categories.Category;
41+
import org.junit.runner.RunWith;
42+
43+
import static android.support.test.espresso.Espresso.onView;
44+
import static android.support.test.espresso.action.ViewActions.click;
45+
import static android.support.test.espresso.intent.Intents.intended;
46+
import static android.support.test.espresso.intent.matcher.BundleMatchers.hasEntry;
47+
import static android.support.test.espresso.intent.matcher.IntentMatchers.hasComponent;
48+
import static android.support.test.espresso.intent.matcher.IntentMatchers.hasExtras;
49+
import static android.support.test.espresso.matcher.ViewMatchers.withId;
50+
51+
import static org.catrobat.catroid.common.Constants.LIBRARY_LOOKS_URL;
52+
import static org.catrobat.catroid.uiespresso.content.brick.utils.BrickDataInteractionWrapper.onBrickAtPosition;
53+
import static org.hamcrest.Matchers.equalTo;
54+
import static org.hamcrest.core.AllOf.allOf;
55+
56+
@RunWith(AndroidJUnit4.class)
57+
public class SetLookBrickTest {
58+
private int brickPosition;
59+
60+
@Rule
61+
public BaseActivityInstrumentationRule<SpriteActivity> baseActivityTestRule = new
62+
BaseActivityInstrumentationRule<>(SpriteActivity.class, SpriteActivity.EXTRA_FRAGMENT_POSITION, SpriteActivity.FRAGMENT_SCRIPTS);
63+
64+
@Before
65+
public void setUp() throws Exception {
66+
brickPosition = 1;
67+
BrickTestUtils.createProjectAndGetStartScript("SetBackgroundBrickTest")
68+
.addBrick(new SetLookBrick());
69+
baseActivityTestRule.launchActivity();
70+
}
71+
72+
@Category({Cat.AppUi.class, Level.Smoke.class})
73+
@Test
74+
public void testSetLookBrickMediaLibraryUrl() {
75+
onBrickAtPosition(0).checkShowsText(R.string.brick_when_started);
76+
onBrickAtPosition(brickPosition).checkShowsText(R.string.brick_set_look);
77+
78+
onBrickAtPosition(brickPosition).onSpinner(R.id.brick_set_look_spinner)
79+
.performSelect(R.string.brick_variable_spinner_create_new_variable);
80+
81+
Intents.init();
82+
83+
onView(withId(R.id.dialog_new_look_media_library))
84+
.perform(click());
85+
86+
intended(allOf(hasComponent(WebViewActivity.class.getName()),
87+
hasExtras(allOf(hasEntry(equalTo(WebViewActivity.INTENT_PARAMETER_URL),
88+
equalTo(LIBRARY_LOOKS_URL))))));
89+
90+
Intents.release();
91+
}
92+
}

catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/content/brick/utils/BrickTestUtils.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public static Script createProjectAndGetStartScript(String projectName) {
4545
project.getDefaultScene().addSprite(sprite);
4646
ProjectManager.getInstance().setProject(project);
4747
ProjectManager.getInstance().setCurrentSprite(sprite);
48+
ProjectManager.getInstance().setCurrentlyEditedScene(project.getDefaultScene());
4849
return script;
4950
}
5051
}

catroid/src/main/java/org/catrobat/catroid/ProjectManager.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.catrobat.catroid.common.LookData;
3333
import org.catrobat.catroid.common.ScreenModes;
3434
import org.catrobat.catroid.common.SoundInfo;
35+
import org.catrobat.catroid.content.CollisionScript;
3536
import org.catrobat.catroid.content.Project;
3637
import org.catrobat.catroid.content.Scene;
3738
import org.catrobat.catroid.content.Script;
@@ -169,6 +170,7 @@ public void loadProject(String projectName, Context context) throws LoadingProje
169170

170171
makeShallowCopiesDeepAgain(project);
171172
checkNestingBrickReferences(true, false);
173+
updateCollisionScriptsSpriteReference(project);
172174

173175
if (project.getCatrobatLanguageVersion() == Constants.CURRENT_CATROBAT_LANGUAGE_VERSION) {
174176
localizeBackgroundSprite(context);
@@ -623,6 +625,19 @@ private void correctAllNestedReferences(Script script) {
623625
}
624626
}
625627

628+
private void updateCollisionScriptsSpriteReference(Project project) {
629+
for (Scene scene : project.getSceneList()) {
630+
for (Sprite sprite : scene.getSpriteList()) {
631+
for (Script script : sprite.getScriptList()) {
632+
if (script instanceof CollisionScript) {
633+
CollisionScript collisionScript = (CollisionScript) script;
634+
collisionScript.updateSpriteToCollideWith(scene);
635+
}
636+
}
637+
}
638+
}
639+
}
640+
626641
private class SaveProjectAsynchronousTask extends AsyncTask<Void, Void, Void> {
627642

628643
@Override

catroid/src/main/java/org/catrobat/catroid/content/CollisionScript.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,22 @@ public String getSpriteToCollideWithName() {
6060

6161
public void setSpriteToCollideWithName(String spriteToCollideWithName) {
6262
this.spriteToCollideWithName = spriteToCollideWithName;
63-
updateSpriteToCollideWith();
63+
updateSpriteToCollideWith(ProjectManager.getInstance().getCurrentlyEditedScene());
6464
}
6565

6666
public Sprite getSpriteToCollideWith() {
67-
updateSpriteToCollideWith();
67+
updateSpriteToCollideWith(ProjectManager.getInstance().getCurrentlyEditedScene());
6868
return spriteToCollideWith;
6969
}
7070

71-
private void updateSpriteToCollideWith() {
72-
if (spriteToCollideWithName != null
73-
&& (spriteToCollideWith == null || !spriteToCollideWithName.equals(spriteToCollideWith.getName()))) {
74-
Scene currentScene = ProjectManager.getInstance().getCurrentlyEditedScene();
75-
spriteToCollideWith = currentScene.getSprite(spriteToCollideWithName);
71+
public void updateSpriteToCollideWith(Scene scene) {
72+
if (spriteToCollideWithName == null) {
73+
spriteToCollideWith = null;
74+
} else {
75+
spriteToCollideWith = scene.getSprite(spriteToCollideWithName);
76+
if (spriteToCollideWith == null) {
77+
spriteToCollideWithName = null;
78+
}
7679
}
7780
}
7881

catroid/src/main/java/org/catrobat/catroid/content/Scene.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828

2929
import org.catrobat.catroid.content.bricks.Brick;
3030
import org.catrobat.catroid.content.bricks.BroadcastMessageBrick;
31-
import org.catrobat.catroid.content.bricks.UserListBrick;
32-
import org.catrobat.catroid.content.bricks.UserVariableBrick;
3331
import org.catrobat.catroid.formulaeditor.datacontainer.DataContainer;
3432
import org.catrobat.catroid.io.XStreamFieldKeyOrder;
3533
import org.catrobat.catroid.physics.PhysicsWorld;
@@ -203,20 +201,4 @@ public Set<String> getBroadcastMessagesInUse() {
203201
}
204202
return messagesInUse;
205203
}
206-
207-
public synchronized void correctUserVariableAndListReferences() {
208-
for (Sprite sprite : spriteList) {
209-
for (Brick brick : sprite.getAllBricks()) {
210-
if (brick instanceof UserVariableBrick) {
211-
((UserVariableBrick) brick).setUserVariable(dataContainer.getUserVariable(sprite,
212-
((UserVariableBrick) brick).getUserVariable().getName()));
213-
}
214-
215-
if (brick instanceof UserListBrick) {
216-
((UserListBrick) brick).setUserList(dataContainer.getUserList(sprite,
217-
((UserListBrick) brick).getUserList().getName()));
218-
}
219-
}
220-
}
221-
}
222204
}

catroid/src/main/java/org/catrobat/catroid/content/bricks/SetLookBrick.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public boolean onNewOptionInDropDownClicked(View v) {
135135
spinnerSelectionBuffer = spinner.getSelectedItemPosition();
136136
new NewLookDialogFragment(this,
137137
ProjectManager.getInstance().getCurrentlyEditedScene(),
138-
ProjectManager.getInstance().getCurrentSprite()) {
138+
getSprite()) {
139139

140140
@Override
141141
public void onCancel(DialogInterface dialog) {

0 commit comments

Comments
 (0)