Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.xtremelabs.robolectric.shadows;

import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import com.xtremelabs.robolectric.internal.Implementation;
import com.xtremelabs.robolectric.internal.Implements;

@Implements(ListFragment.class)
public class ShadowListFragment extends ShadowFragment {

final private AdapterView.OnItemClickListener mOnClickListener = //
new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
onListItemClick((ListView) parent, v, position, id);
}
};

@Implementation
public void onViewCreated(View view, Bundle savedInstanceState) {
ListView list = (ListView) view.findViewById(android.R.id.list);
list.setOnItemClickListener(mOnClickListener);
}

@Implementation
public void onListItemClick(ListView l, View v, int position, long id) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@

import static org.fest.assertions.Assertions.assertThat;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

import org.androidannotations.test15.AndroidAnnotationsTestRunner;

/**
* Those test are disabled for now, we need to update Robolectric version for
* fragment support, however we'll have to solve other issues to do so.
Expand All @@ -48,14 +42,4 @@ public void can_inject_native_fragment_with_id() {
assertThat(activity.myFragment2).isNotNull();
}

// @Test
public void can_inject_support_fragment_with_default_id() {
assertThat(activity.mySupportFragment).isNotNull();
}

// @Test
public void can_inject_support_fragment_with_id() {
assertThat(activity.mySupportFragment2).isNotNull();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package org.androidannotations.test15.efragment;

import static org.fest.assertions.Assertions.assertThat;

import org.androidannotations.test15.AndroidAnnotationsTestRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.widget.ListView;

import com.xtremelabs.robolectric.Robolectric;
import com.xtremelabs.robolectric.shadows.ShadowListFragment;

@RunWith(AndroidAnnotationsTestRunner.class)
public class MyListFragmentTest {

private static final int TESTED_CLICKED_INDEX = 4;

MyListFragment_ myListFragment;

@Before
public void setup() {
Robolectric.bindShadowClass(ShadowListFragment.class);

myListFragment = new MyListFragment_();
startFragment(myListFragment);
}

@Test
public void is_item_click_available_from_list_fragment() {
ListView listView = (ListView) myListFragment.findViewById(android.R.id.list);
long itemId = listView.getAdapter().getItemId(TESTED_CLICKED_INDEX);
View view = listView.getChildAt(TESTED_CLICKED_INDEX);

assertThat(myListFragment.listItemClicked).isFalse();
listView.performItemClick(view, TESTED_CLICKED_INDEX, itemId);
assertThat(myListFragment.listItemClicked).isTrue();
}

public static void startFragment(Fragment fragment) {
FragmentManager fragmentManager = new FragmentActivity().getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.add(fragment, null);
fragmentTransaction.commit();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* Copyright (C) 2010-2012 eBusiness Information, Excilys Group
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed To in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.androidannotations.test15.efragment;

import static org.fest.assertions.Assertions.assertThat;

import org.androidannotations.test15.AndroidAnnotationsTestRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(AndroidAnnotationsTestRunner.class)
public class MySupportFragmentActivityTest {

private MySupportFragmentActivity_ activity;

@Before
public void setup() {
activity = new MySupportFragmentActivity_();
activity.onCreate(null);
}

@Test
public void can_inject_support_fragment_with_default_id() {
assertThat(activity.mySupportFragment).isNotNull();
}

@Test
public void can_inject_support_fragment_with_id() {
assertThat(activity.mySupportFragment2).isNotNull();
}

@Test
public void can_inject_support_fragment_with_default_tag() {
assertThat(activity.mySupportFragmentTag).isNotNull();
}

@Test
public void can_inject_support_fragment_with_tag() {
assertThat(activity.mySupportFragmentTag2).isNotNull();
}

}
3 changes: 2 additions & 1 deletion 3 AndroidAnnotations/functional-test-1-5/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
<activity android:name="org.androidannotations.test15.nonconfiguration.NonConfigurationActivity_" />
<activity android:name="org.androidannotations.test15.sherlock.MySherlockActivity_" />
<activity android:name="org.androidannotations.test15.efragment.MyFragmentActivity_" />
<activity android:name="org.androidannotations.test15.efragment.MySupportFragmentActivity_" />
<activity android:name="org.androidannotations.test15.afterviews.AfterViewsActivity_" />
<activity android:name=".SSLConnection_" />
<activity android:name="org.androidannotations.test15.SeekBarChangeListenedActivity_" />
Expand All @@ -82,7 +83,7 @@

<service
android:name="org.androidannotations.test15.eservice.MyService_"
exported="false" />
android:exported="false" />
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,4 @@
android:layout_height="fill_parent"
android:layout_weight="1" />

<fragment
android:id="@+id/mySupportFragment"
android:tag="mySupportFragmentTag"
android:name="org.androidannotations.test15.efragment.MySupportFragment_"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1" />

</LinearLayout>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="8dp"
android:paddingRight="8dp" >

<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#00FF00"
android:drawSelectorOnTop="false" />

<TextView
android:id="@android:id/empty"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FF0000"
android:text="No data" />

</LinearLayout>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<!--

Copyright (C) 2010-2012 eBusiness Information, Excilys Group

Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed To in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License.

-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >

<fragment
android:id="@+id/mySupportFragment"
android:tag="mySupportFragmentTag"
android:name="org.androidannotations.test15.efragment.MySupportFragment_"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1" />

</LinearLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,13 @@ public class BeanWithFragments {
@FragmentById
public MyFragment myFragment;

@FragmentById
public MySupportFragment mySupportFragment;

@FragmentById(R.id.myFragment)
public MyFragment myFragment2;

@FragmentById(R.id.mySupportFragment)
public MySupportFragment mySupportFragment2;

@FragmentByTag
public MyFragment myFragmentTag;

@FragmentByTag
public MySupportFragment mySupportFragmentTag;

@FragmentByTag("myFragmentTag")
public MyFragment myFragmentTag2;

@FragmentByTag("mySupportFragmentTag")
public MySupportFragment mySupportFragmentTag2;



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Copyright (C) 2010-2012 eBusiness Information, Excilys Group
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed To in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.androidannotations.test15.efragment;

import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.FragmentById;
import org.androidannotations.annotations.FragmentByTag;
import org.androidannotations.test15.R;

@EBean
public class BeanWithSupportFragments {

@FragmentById
public MySupportFragment mySupportFragment;

@FragmentById(R.id.mySupportFragment)
public MySupportFragment mySupportFragment2;

@FragmentByTag
public MySupportFragment mySupportFragmentTag;

@FragmentByTag("mySupportFragmentTag")
public MySupportFragment mySupportFragmentTag2;

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,41 +15,30 @@
*/
package org.androidannotations.test15.efragment;

import android.support.v4.app.FragmentActivity;

import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.FragmentById;
import org.androidannotations.annotations.FragmentByTag;
import org.androidannotations.test15.R;

import android.app.Activity;


@EActivity(R.layout.fragments)
public class MyFragmentActivity extends FragmentActivity {
public class MyFragmentActivity extends Activity {

@FragmentById
public MyFragment myFragment;

@FragmentById
public MySupportFragment mySupportFragment;

@FragmentById(R.id.myFragment)
public MyFragment myFragment2;

@FragmentById(R.id.mySupportFragment)
public MySupportFragment mySupportFragment2;

@FragmentByTag
public MyFragment myFragmentTag;

@FragmentByTag
public MySupportFragment mySupportFragmentTag;

@FragmentByTag("myFragmentTag")
public MyFragment myFragmentTag2;

@FragmentByTag("mySupportFragmentTag")
public MySupportFragment mySupportFragmentTag2;

@Bean
public BeanWithFragments beanWithFragments;

Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.